# HG changeset patch # User shivsood # Date 1286541446 -19800 # Node ID 59dfe4ae66d0b924f52510897d2ddb35c0b2ed3d RCS IM Library - Initial implementation diff -r 000000000000 -r 59dfe4ae66d0 commonimlib/bwins/commonimlibu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commonimlib/bwins/commonimlibu.def Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,27 @@ +EXPORTS + ?getStaticMetaObject@MChatSessionIntf@RcsIMLib@@SAABUQMetaObject@@XZ @ 1 NONAME ; struct QMetaObject const & RcsIMLib::MChatSessionIntf::getStaticMetaObject(void) + ?sessionTerminated@MChatContactManagerIntf@RcsIMLib@@IAEXIPAVMChatSessionIntf@2@@Z @ 2 NONAME ; void RcsIMLib::MChatContactManagerIntf::sessionTerminated(unsigned int, class RcsIMLib::MChatSessionIntf *) + ?trUtf8@MChatSessionIntf@RcsIMLib@@SA?AVQString@@PBD0@Z @ 3 NONAME ; class QString RcsIMLib::MChatSessionIntf::trUtf8(char const *, char const *) + ?errorMessage@MChatSessionIntf@RcsIMLib@@IAEXVQString@@@Z @ 4 NONAME ; void RcsIMLib::MChatSessionIntf::errorMessage(class QString) + ?trUtf8@MChatContactManagerIntf@RcsIMLib@@SA?AVQString@@PBD0H@Z @ 5 NONAME ; class QString RcsIMLib::MChatContactManagerIntf::trUtf8(char const *, char const *, int) + ?newChatData@MChatSessionIntf@RcsIMLib@@IAEXVQString@@@Z @ 6 NONAME ; void RcsIMLib::MChatSessionIntf::newChatData(class QString) + ?tr@MChatContactManagerIntf@RcsIMLib@@SA?AVQString@@PBD0H@Z @ 7 NONAME ; class QString RcsIMLib::MChatContactManagerIntf::tr(char const *, char const *, int) + ?staticMetaObject@MChatContactManagerIntf@RcsIMLib@@2UQMetaObject@@B @ 8 NONAME ; struct QMetaObject const RcsIMLib::MChatContactManagerIntf::staticMetaObject + ?trUtf8@MChatContactManagerIntf@RcsIMLib@@SA?AVQString@@PBD0@Z @ 9 NONAME ; class QString RcsIMLib::MChatContactManagerIntf::trUtf8(char const *, char const *) + ?tr@MChatSessionIntf@RcsIMLib@@SA?AVQString@@PBD0H@Z @ 10 NONAME ; class QString RcsIMLib::MChatSessionIntf::tr(char const *, char const *, int) + ?sessionEstablised@MChatContactManagerIntf@RcsIMLib@@IAEXIPAVMChatSessionIntf@2@@Z @ 11 NONAME ; void RcsIMLib::MChatContactManagerIntf::sessionEstablised(unsigned int, class RcsIMLib::MChatSessionIntf *) + ?qt_metacast@MChatSessionIntf@RcsIMLib@@UAEPAXPBD@Z @ 12 NONAME ; void * RcsIMLib::MChatSessionIntf::qt_metacast(char const *) + ?incomingChatSession@MChatContactManagerIntf@RcsIMLib@@IAEXIVQString@@0I@Z @ 13 NONAME ; void RcsIMLib::MChatContactManagerIntf::incomingChatSession(unsigned int, class QString, class QString, unsigned int) + ?metaObject@MChatSessionIntf@RcsIMLib@@UBEPBUQMetaObject@@XZ @ 14 NONAME ; struct QMetaObject const * RcsIMLib::MChatSessionIntf::metaObject(void) const + ?qt_metacall@MChatSessionIntf@RcsIMLib@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 15 NONAME ; int RcsIMLib::MChatSessionIntf::qt_metacall(enum QMetaObject::Call, int, void * *) + ?trUtf8@MChatSessionIntf@RcsIMLib@@SA?AVQString@@PBD0H@Z @ 16 NONAME ; class QString RcsIMLib::MChatSessionIntf::trUtf8(char const *, char const *, int) + ?tr@MChatContactManagerIntf@RcsIMLib@@SA?AVQString@@PBD0@Z @ 17 NONAME ; class QString RcsIMLib::MChatContactManagerIntf::tr(char const *, char const *) + ?metaObject@MChatContactManagerIntf@RcsIMLib@@UBEPBUQMetaObject@@XZ @ 18 NONAME ; struct QMetaObject const * RcsIMLib::MChatContactManagerIntf::metaObject(void) const + ?getStaticMetaObject@MChatContactManagerIntf@RcsIMLib@@SAABUQMetaObject@@XZ @ 19 NONAME ; struct QMetaObject const & RcsIMLib::MChatContactManagerIntf::getStaticMetaObject(void) + ?qt_metacall@MChatContactManagerIntf@RcsIMLib@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 20 NONAME ; int RcsIMLib::MChatContactManagerIntf::qt_metacall(enum QMetaObject::Call, int, void * *) + ?additionalInfo@MChatSessionIntf@RcsIMLib@@IAEXVQString@@@Z @ 21 NONAME ; void RcsIMLib::MChatSessionIntf::additionalInfo(class QString) + ?qt_metacast@MChatContactManagerIntf@RcsIMLib@@UAEPAXPBD@Z @ 22 NONAME ; void * RcsIMLib::MChatContactManagerIntf::qt_metacast(char const *) + ?staticMetaObject@MChatSessionIntf@RcsIMLib@@2UQMetaObject@@B @ 23 NONAME ; struct QMetaObject const RcsIMLib::MChatSessionIntf::staticMetaObject + ?tr@MChatSessionIntf@RcsIMLib@@SA?AVQString@@PBD0@Z @ 24 NONAME ; class QString RcsIMLib::MChatSessionIntf::tr(char const *, char const *) + ?createIMManager@ChatImplFactory@@SAPAVMChatContactManagerIntf@RcsIMLib@@VQString@@@Z @ 25 NONAME ; class RcsIMLib::MChatContactManagerIntf * ChatImplFactory::createIMManager(class QString) + diff -r 000000000000 -r 59dfe4ae66d0 commonimlib/commonimlib.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commonimlib/commonimlib.pro Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,48 @@ +# +#Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +#All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html." +# Initial Contributors: +# Nokia Corporation - initial contribution. +# Contributors: +# +# Description: +# RCS IM Library - Initial version +# +# + +TEMPLATE = lib +TARGET = commonimlib + +QT += core + +DEPENDPATH += ./inc \ + ./src + +DEFINES += COMMONIMLIB_BUILD + +INCLUDEPATH += ./inc +INCLUDEPATH += ../epoc32/include/app + +HEADERS += inc/chatimplfactory.h \ + inc/chatinterfaces.h \ + inc/immanagerfactory.h \ + inc/imlib_common.h + +SOURCES += src/chatimplfactory.cpp + +symbian: { + TARGET.CAPABILITY += All -Tcb + TARGET.UID3 = 0xE41BBB83 + TARGET.EPOCALLOWDLLDATA=1 + :BLD_INF_RULES.prj_exports += "inc/chatimplfactory.h APP_LAYER_PLATFORM_EXPORT_PATH(chatimplfactory.h)" + :BLD_INF_RULES.prj_exports += "inc/chatinterfaces.h APP_LAYER_PLATFORM_EXPORT_PATH(chatinterfaces.h)" + :BLD_INF_RULES.prj_exports += "inc/imlib_common.h APP_LAYER_PLATFORM_EXPORT_PATH(imlib_common.h)" + :BLD_INF_RULES.prj_exports += "inc/immanagerfactory.h APP_LAYER_PLATFORM_EXPORT_PATH(immanagerfactory.h)" +} + +win32:include(commonimlib_installs_win32.pri) + diff -r 000000000000 -r 59dfe4ae66d0 commonimlib/eabi/commonimlibu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commonimlib/eabi/commonimlibu.def Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,23 @@ +EXPORTS + _ZN15ChatImplFactory15createIMManagerE7QString @ 1 NONAME + _ZN8RcsIMLib16MChatSessionIntf11newChatDataE7QString @ 2 NONAME + _ZN8RcsIMLib16MChatSessionIntf11qt_metacallEN11QMetaObject4CallEiPPv @ 3 NONAME + _ZN8RcsIMLib16MChatSessionIntf11qt_metacastEPKc @ 4 NONAME + _ZN8RcsIMLib16MChatSessionIntf12errorMessageE7QString @ 5 NONAME + _ZN8RcsIMLib16MChatSessionIntf14additionalInfoE7QString @ 6 NONAME + _ZN8RcsIMLib16MChatSessionIntf16staticMetaObjectE @ 7 NONAME DATA 16 + _ZN8RcsIMLib16MChatSessionIntf19getStaticMetaObjectEv @ 8 NONAME + _ZN8RcsIMLib23MChatContactManagerIntf11qt_metacallEN11QMetaObject4CallEiPPv @ 9 NONAME + _ZN8RcsIMLib23MChatContactManagerIntf11qt_metacastEPKc @ 10 NONAME + _ZN8RcsIMLib23MChatContactManagerIntf16staticMetaObjectE @ 11 NONAME DATA 16 + _ZN8RcsIMLib23MChatContactManagerIntf17sessionEstablisedEjPNS_16MChatSessionIntfE @ 12 NONAME + _ZN8RcsIMLib23MChatContactManagerIntf17sessionTerminatedEjPNS_16MChatSessionIntfE @ 13 NONAME + _ZN8RcsIMLib23MChatContactManagerIntf19getStaticMetaObjectEv @ 14 NONAME + _ZN8RcsIMLib23MChatContactManagerIntf19incomingChatSessionEj7QStringS1_j @ 15 NONAME + _ZNK8RcsIMLib16MChatSessionIntf10metaObjectEv @ 16 NONAME + _ZNK8RcsIMLib23MChatContactManagerIntf10metaObjectEv @ 17 NONAME + _ZTIN8RcsIMLib16MChatSessionIntfE @ 18 NONAME + _ZTIN8RcsIMLib23MChatContactManagerIntfE @ 19 NONAME + _ZTVN8RcsIMLib16MChatSessionIntfE @ 20 NONAME + _ZTVN8RcsIMLib23MChatContactManagerIntfE @ 21 NONAME + diff -r 000000000000 -r 59dfe4ae66d0 commonimlib/inc/chatimplfactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commonimlib/inc/chatimplfactory.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial Version +* +*/ + +#ifndef __CHAT_IMPL_FACTORY__ +#define __CHAT_IMPL_FACTORY__ + +#include "imlib_common.h" +#include + +namespace RcsIMLib +{ + class MChatContactManagerIntf; +} + +class COMMONIMLIB_EXPORT ChatImplFactory +{ + public: + static RcsIMLib::MChatContactManagerIntf* createIMManager(QString protocol); +}; + + +#endif diff -r 000000000000 -r 59dfe4ae66d0 commonimlib/inc/chatinterfaces.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commonimlib/inc/chatinterfaces.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + +#ifndef __CHATINTERFACES_H__ +#define __CHATINTERFACES_H__ + +#include +#include +#include +#include +#include "qmobilityglobal.h" +#include + +QTM_BEGIN_NAMESPACE +class QContact; +QTM_END_NAMESPACE + +QTM_USE_NAMESPACE + +namespace RcsIMLib +{ + +typedef unsigned int QChatContactId; +typedef unsigned int RcsChatId; + +/* + * Manages creation of a new session, notification for incoming + * session, closing the session. Also manages sending of + * IM Message, and notification of incoming message, + * and error notification. + */ +class MChatSessionIntf; + +/* Manages fetching and Managing of contacts for + * chat. The APIs allow for fetching of the list +* of contacts and also their presence information. + * Also the status message can be filled up if supported. + */ +class COMMONIMLIB_EXPORT MChatContactManagerIntf: public QObject +{ + Q_OBJECT + public: + /* Also APIs need to be there for setting status message, + * and presence info etc */ + + virtual RcsChatId createChatSession(QContactLocalId contactId, QString initMsg)=0; + virtual void closeSession(RcsChatId sessID)=0; + virtual void acceptIncomingSession(RcsChatId sessID)=0; + +signals: + void incomingChatSession(QContactLocalId aMyBuddyID, QString incomingSipUri, QString initMsg, RcsIMLib::RcsChatId sessID); + void sessionEstablised(RcsIMLib::RcsChatId sessID, RcsIMLib::MChatSessionIntf* chatSession); + void sessionTerminated(RcsIMLib::RcsChatId sessID, RcsIMLib::MChatSessionIntf* chatSession); + +}; + +/* The interface used to initiate a chat session with a + * particular contact. + * The ChatSessionManager is symbolised by an instance of MChatInterface + */ +class COMMONIMLIB_EXPORT MChatSessionIntf: public QObject +{ + Q_OBJECT + public: + + /* Creates a chat session with the specified contact. + * If the session creation was successful the MChatSessionManagerIntf + * returned will be a valid pointer. + */ + virtual bool sendChatData(QString newChatData)=0; + virtual bool endChatSession()=0; + + //Dirty APIs :( + //Use this API to set any Platform Parameters + virtual void setPlatformParams(void *apPlatFormParam)=0; + //Get the Platform implementations + virtual void* getPlatformImpl()=0; + + signals: + void newChatData(QString newChatData); + /* Notifies of error and the appropriate error + * string */ + void errorMessage(QString errorString); + /* Additional info such as, + * User is typing a message etc, + * The same will be reset by giving an empty string + * when appropriate.*/ + void additionalInfo(QString additionalInfo); + + +}; + +} //namespace + +#endif //__CHATINTERFACES_H__ + diff -r 000000000000 -r 59dfe4ae66d0 commonimlib/inc/imlib_common.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commonimlib/inc/imlib_common.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + +#ifndef __COMMON_IMLIB_H__ +#define __COMMON_IMLIB_H__ + +#include + +#if defined(COMMONIMLIB_BUILD) +#define COMMONIMLIB_EXPORT Q_DECL_EXPORT +#else +#define COMMONIMLIB_EXPORT Q_DECL_IMPORT +#endif + +#endif + + diff -r 000000000000 -r 59dfe4ae66d0 commonimlib/inc/immanagerfactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commonimlib/inc/immanagerfactory.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#ifndef __IMMANAGER_FACTORY__ +#define __IMMANAGER_FACTORY__ + +#include +#include + +namespace RcsIMLib +{ + class MChatContactManagerIntf; +} + +class IMManagerFactory +{ + public: + virtual RcsIMLib::MChatContactManagerIntf* createIMManager()=0; + virtual QString protocol()=0; +}; + +Q_DECLARE_INTERFACE(IMManagerFactory, "com.nokia.qt.Plugin.IMManagerFactory/1.0"); + +#endif diff -r 000000000000 -r 59dfe4ae66d0 commonimlib/src/chatimplfactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commonimlib/src/chatimplfactory.cpp Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#include "chatinterfaces.h" +#include "immanagerfactory.h" +#include "chatimplfactory.h" +#include +#include +#include +#include +#include + +RcsIMLib::MChatContactManagerIntf* ChatImplFactory::createIMManager(QString protocol) +{ +#ifdef Q_OS_SYMBIAN + QDir pluginsDir = QLibraryInfo::location(QLibraryInfo::PluginsPath) + "/IMLIB"; +#else + QDir pluginsDir = QCoreApplication::applicationDirPath() + "/resource/qt/plugins/IMLIB"; +#endif + /* Now doing a dirty implementation. + * The real thing to do is parse manifests and compare each plugin for + * the protocol string + */ + IMManagerFactory* imManagerFact=0; + foreach (QString fileName, pluginsDir.entryList(QDir::Files)) + { + QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); + QObject *plugin = pluginLoader.instance(); + if (plugin) + { + imManagerFact = qobject_cast(plugin); + if (imManagerFact && imManagerFact->protocol()==protocol) + { + RcsIMLib::MChatContactManagerIntf* imManager = imManagerFact->createIMManager(); + //delete imManagerFact; + return imManager; + } + //delete imManagerFact; + imManagerFact = 0; + } + } + return 0; +} + diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/inc/chatcontactmanager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/inc/chatcontactmanager.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#ifndef __CHATCONTACT_MANAGER_H__ +#define __CHATCONTACT_MANAGER_H__ + +#include "chatinterfaces.h" +//#include "rcschatengine_globals.h" + +class ChatContactManagerImpl; + +/* Interface implementation of MChatContactIntf + */ +class ChatContactManager: public RcsIMLib::MChatContactManagerIntf +{ + Q_OBJECT + public: + ChatContactManager(); + ~ChatContactManager(); + RcsIMLib::RcsChatId createChatSession(QContactLocalId contactId, QString initMsg); + void closeSession(RcsIMLib::RcsChatId sessID); + void acceptIncomingSession(RcsIMLib::RcsChatId sessID); + + + private: + ChatContactManagerImpl *mpImpl; + friend class ChatContactManagerImpl; +}; + +#endif //__CHATCONTACT_MANAGER_H__ diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/inc/chatcontactmanagerimpl_sym.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/inc/chatcontactmanagerimpl_sym.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,148 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#ifndef __CHATCONTACT_MANAGER_IMPL_SYM_H__ +#define __CHATCONTACT_MANAGER_IMPL_SYM_H__ + + +#include +#include +#include "chatinterfaces.h" +#include "qmobilityglobal.h" +#include "qcontactfilter.h" +#include "qcontactdetailfilter.h" +#include "qtcontactsglobal.h" + + +//SIP and MCE Specific Headers +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//Profile agent, SIP stack inclusions +#include +#include +#include +#include + +//#include "rcschatengine_globals.h" + +class TMsrpChatSession; +class CContactItem; +class ChatContactManager; +class ContactView; + + + +QTM_BEGIN_NAMESPACE +class QContact; +class QContactDetailFilterPrivate; +QTM_END_NAMESPACE + +QTM_USE_NAMESPACE + +const TInt KGranularity = 12; +const TInt KAcceptSize = 24; +/* Interface implementation of MChatContactIntf */ +class ChatContactManagerImpl: public QObject, + public MMceSessionObserver, + public MSIPProfileRegistryObserver, // for CSIPProfileRegistry + public MSIPObserver, // for CSIP + public MMceInSessionObserver, // for incoming sessions from MCE + public MMceDataSinkObserver + +{ + public: + ChatContactManagerImpl(ChatContactManager *apCntManager); + ~ChatContactManagerImpl(); + + + + /* Setup MCE Manager */ + RcsIMLib::RcsChatId createChatSession(QContactLocalId contactId, QString initMsg); + void closeSession(RcsIMLib::RcsChatId sessID); + void acceptIncomingSession(RcsIMLib::RcsChatId sessID); + + + // From MMceSessionObserver + void SessionStateChanged(CMceSession& aSession, TMceTransactionDataContainer* aContainer); + void SessionConnectionStateChanged(CMceSession& aSession, TBool aActive ); + void Failed( CMceSession& aSession, TInt aError ); + void UpdateFailed(CMceSession& aSession, TMceTransactionDataContainer* aContainer ); + + // From MSIPProfileAgentObserver + void ProfileRegistryEventOccurred(TUint32 aProfileId, TEvent aEvent); + void ProfileRegistryErrorOccurred(TUint32 aProfileId, TInt aError); + + // From MSIPObserver + void IncomingRequest(TUint32 aIapId, CSIPServerTransaction* aTransaction); + void TimedOut(CSIPServerTransaction& aTransaction); + + // From MMceInSessionObserver + void IncomingSession(CMceInSession* aSession, TMceTransactionDataContainer* aContainer ); + void IncomingUpdate(CMceSession& aOrigSession, CMceInSession* aUpdatedSession, TMceTransactionDataContainer* aContainer ); + void DataReceived(CMceMediaStream& aStream,CMceMediaSink& aSink, const TDesC8& aData); + + private: + void setupMceManagerL(); + RcsIMLib::RcsChatId createChatSessionL(QContactLocalId contactId, QString initMsg); + void GetStreams(CMceSession& aSession, CMceMessageStream*& aUplinkStr, CMceMessageStream*& aDownlinkStr ); + + private: + //Variables here + QContactManager *mManager; + ChatContactManager *mParent; + //SYM Specific Headers + CMceManager *mMceMgr; + CSIP *mSip; + CSIPProfileRegistry *mProfileReg; + CSIPProfile *mProfile; + RPointerArray mMceSessions; + RPointerArray mChatSessionArray; + TMceTransactionDataContainer mDataContainer; + RPointerArray mAllprofiles; + //QList mAllContacts; + //QList mAllSIPContacts; + //QContactLocalId mMyID; + //QContactLocalId mMyBuddyID; + //QString mMyFirstName; + //QContactDetailFilter mFilter; + HBufC8 *mOriginatorUri; + + +}; +#endif //__CHATCONTACT_MANAGER_IMPL_SYM_H__ diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/inc/chatinterfaces.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/inc/chatinterfaces.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + + +/* A set of interfaces to be implemented by providers for chat application. + */ + +#ifndef __CHATINTERFACES_H__ +#define __CHATINTERFACES_H__ + +#include +#include +#include +#include + + +QTM_BEGIN_NAMESPACE +class QContact; +QTM_END_NAMESPACE + +QTM_USE_NAMESPACE + +namespace RcsIMLib +{ + +typedef unsigned int RcsChatId; + +/* + * Manages creation of a new session, notification for incoming + * session, closing the session. Also manages sending of + * IM Message, and notification of incoming message, + * and error notification. + */ +class MChatSessionIntf; + +/* Manages fetching and Managing of contacts for + * chat. The APIs allow for fetching of the list +* of contacts and also their presence information. + * Also the status message can be filled up if supported. + */ +class MChatContactManagerIntf: public QObject +{ + Q_OBJECT + public: + /* Also APIs need to be there for setting status message, + * and presence info etc */ + + virtual RcsChatId createChatSession(QContactLocalId contactId, QString initMsg)=0; + virtual void closeSession(RcsChatId sessID)=0; + virtual void acceptIncomingSession(RcsChatId sessID)=0; + +signals: + void incomingChatSession(QContactLocalId aMyBuddyID, QString incomingSipUri, QString initMsg, RcsIMLib::RcsChatId sessID); + void sessionEstablised(RcsIMLib::RcsChatId sessID, RcsIMLib::MChatSessionIntf* chatSession); + void sessionTerminated(RcsIMLib::RcsChatId sessID, RcsIMLib::MChatSessionIntf* chatSession); + +}; + +/* The interface used to initiate a chat session with a + * particular contact. + * The ChatSessionManager is symbolised by an instance of MChatInterface + */ +class MChatSessionIntf: public QObject +{ + Q_OBJECT + public: + + /* Creates a chat session with the specified contact. + * If the session creation was successful the MChatSessionManagerIntf + * returned will be a valid pointer. + */ + virtual bool sendChatData(QString newChatData)=0; + virtual bool endChatSession()=0; + + //Dirty APIs :( + //Use this API to set any Platform Parameters + virtual void setPlatformParams(void *apPlatFormParam)=0; + //Get the Platform implementations + virtual void* getPlatformImpl()=0; + + signals: + void newChatData(QString newChatData); + /* Notifies of error and the appropriate error + * string */ + void errorMessage(QString errorString); + /* Additional info such as, + * User is typing a message etc, + * The same will be reset by giving an empty string + * when appropriate.*/ + void additionalInfo(QString additionalInfo); + + +}; + +} //namespace + +#endif //__CHATINTERFACES_H__ + diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/inc/chatsession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/inc/chatsession.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#ifndef __CHATSESSIONMANAGER_H__ +#define __CHATSESSIONMANAGER_H__ + +#include "chatinterfaces.h" +//#include "rcschatengine_globals.h" + +class ChatSessionImpl; + +class ChatSession:public RcsIMLib::MChatSessionIntf +{ + Q_OBJECT + public: + ChatSession(); + + + /* Close the session */ + bool endChatSession(); + bool sendChatData(QString newChatData); + + + void setPlatformParams(void *apPlatFormParam); + + //Get the Platform implementations + void* getPlatformImpl(); + + + private: + ChatSessionImpl *mpImpl; + friend class ChatSessionImpl; +}; + +#endif + diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/inc/chatsessionimpl_sym.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/inc/chatsessionimpl_sym.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#ifndef __CHATSESSION_IMPL_SYM_H__ +#define __CHATSESSION_IMPL_SYM_H__ + +#include +#include "chatinterfaces.h" +#include "chatsession.h" +//#include "rcschatengine_globals.h" + +class TMsrpChatSession; +class CMceMessageSource; +class TDesC8; + + +class ChatSessionImpl: public QObject +{ + Q_OBJECT + public: + ChatSessionImpl(ChatSession *apParent); + + /* Close the session */ + bool endChatSession(); + + bool sendChatData(QString newChatData); + + + //**************** + void setPlatformParams(void *apPlatFormParam); + + //Get the Platform implementations + void* getPlatformImpl(); + void incomingData(const TDesC8& aData); + + + ChatSession *mParent; + TMsrpChatSession* mMsrpChatSessionData; + CMceMessageSource* mMessageSource; + + +}; + +#endif + diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/inc/msrpchatsessiondata_sym.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/inc/msrpchatsessiondata_sym.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#ifndef __MSRP_CHATSESSIONDATA_SYM_H__ +#define __MSRP_CHATSESSIONDATA_SYM_H__ + +//#include "rcschatengine_globals.h" + +class CMceMediaStream; +class CMceSession; +class CMceMediaStream; +class ChatSession; + +class TMsrpChatSession +{ + public: + CMceManager *iMceManager; + CMceSession *iMceSession; + ChatSession *iChatSession; + CMceMediaStream *iStream1; + CMceMediaStream *iStream2; + QString iInitMsg; +}; + +#endif //__MSRP_CHATSESSIONDATA_SYM_H__ diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/inc/rcschatengine_globals.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/inc/rcschatengine_globals.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#ifndef RCSCHATENGINE_GLOBAL_H +#define RCSCHATENGINE_GLOBAL_H + +#include + + +#ifdef RCSCHATENGINE_LIB + #define RCSCHATENGINE_EXPORT Q_DECL_EXPORT +#else + #ifdef RCSCHATENGINE_TEST + #define RCSCHATENGINE_EXPORT + #else + #define RCSCHATENGINE_EXPORT Q_DECL_IMPORT + #endif +#endif + + +#endif diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/inc/rcsimmanagerfactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/inc/rcsimmanagerfactory.h Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#ifndef __RCS_IMMANAGER_FACTORY_H__ +#define __RCS_IMMANAGER_FACTORY_H__ + +#include "immanagerfactory.h" + +class RcsIMManagerFactory: public QObject, public IMManagerFactory +{ + + Q_INTERFACES(IMManagerFactory) + public: + virtual RcsIMLib::MChatContactManagerIntf* createIMManager(); + virtual QString protocol(); +}; +#endif diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/rcsimengine.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/rcsimengine.pro Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,51 @@ +# +# Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html." +# Initial Contributors: +# Nokia Corporation - initial contribution. +# Contributors: +# +# Description: +# RCS IM Library - Initial version + + +TEMPLATE = lib +TARGET = symmsrpplugin +CONFIG += plugin +CONFIG += hb +QT += core + +HEADERS += ./inc/*.h +SOURCES += ./src/*.cpp +INCLUDEPATH += ../epoc32/include/app +INCLUDEPATH += ../commonimlib/inc + +# LIBS += -lxqservice +LIBS += -lInetProtUtil.dll \ + -lbafl.dll \ + -lecom.dll \ + -lesock.dll \ + -lsipclient.dll \ + -lsipcodec.dll \ + -lsipprofile.dll \ + -lsipprofilecli.dll \ + -lmceclient.dll \ + -linsock.dll \ + -lsdpcodec.dll \ + -lcntmodel.dll \ + -lcommonimlib \ + -lqtcontacts \ + +TARGET.CAPABILITY += All \ + -Tcb +symbian: { + TARGET.UID3 = 0xE41BBB83 + :BLD_INF_RULES.prj_exports += "inc/chatcontactmanager.h APP_LAYER_PLATFORM_EXPORT_PATH(chatcontactmanager.h)" + :BLD_INF_RULES.prj_exports += "inc/chatcontactmanagerimpl_sym.h APP_LAYER_PLATFORM_EXPORT_PATH(chatcontactmanagerimpl_sym.h)" + :BLD_INF_RULES.prj_exports += "inc/chatsession.h APP_LAYER_PLATFORM_EXPORT_PATH(chatsession.h)" +} +symbian:include(symmsrpplugin_installs_sym.pri) diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/src/chatcontactmanager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/src/chatcontactmanager.cpp Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#include "chatcontactmanager.h" + +#ifdef Q_OS_SYMBIAN +#include "chatcontactmanagerimpl_sym.h" +#endif + +using namespace RcsIMLib; + +ChatContactManager::ChatContactManager() +{ + mpImpl = new ChatContactManagerImpl(this); +} + +ChatContactManager::~ChatContactManager() + { + delete mpImpl; + } + +RcsIMLib::RcsChatId ChatContactManager::createChatSession(QContactLocalId contactId, QString initMsg) +{ + return mpImpl->createChatSession(contactId, initMsg); +} + +void ChatContactManager::closeSession(RcsIMLib::RcsChatId sessID) +{ + mpImpl->closeSession(sessID); +} + +void ChatContactManager::acceptIncomingSession(RcsIMLib::RcsChatId sessID) +{ + mpImpl->acceptIncomingSession(sessID); +} diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/src/chatcontactmanagerimpl_sym.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/src/chatcontactmanagerimpl_sym.cpp Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,610 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + + +#include +#include +#include +#include +#include +#include +#include +#include "chatsession.h" +#include "chatcontactmanager.h" +#include "chatcontactmanagerimpl_sym.h" +#include "chatsessionimpl_sym.h" +#include "msrpchatsessiondata_sym.h" +#include +#include +#include +#include "qcontactfilter.h" + +using namespace RcsIMLib; + + +ChatContactManagerImpl::ChatContactManagerImpl(ChatContactManager *apCntManager):mParent(apCntManager),mProfile(NULL) +{ + QT_TRAP_THROWING(setupMceManagerL()); + mManager = new QContactManager("symbian"); + + QContact self = mManager->contact(mManager->selfContactId()); + //mMyID = self.localId(); + + // To get Self SIP Uri. + QContactDetail selfContactDetail = self.detail(QContactOnlineAccount::DefinitionName); + const QContactOnlineAccount &onlineUrl = static_cast(selfContactDetail); + QString selfSipUri = onlineUrl.accountUri(); + TPtrC16 dataPtr(reinterpret_cast(selfSipUri.utf16())); + mOriginatorUri = HBufC8::NewL(dataPtr.Length()); + mOriginatorUri->Des().Copy(dataPtr); + +} + + +ChatContactManagerImpl::~ChatContactManagerImpl() + { + + for(int i=0;iState(); + + if (mSessionState <= CMceSession::EEstablished) + mMceSessions[i]->TerminateL(0,0,0); + + } + + mMceSessions.ResetAndDestroy();//deletes streams, sources and sinks + mMceSessions.Close(); + mChatSessionArray.ResetAndDestroy(); + mChatSessionArray.Close(); + delete mManager; + delete mMceMgr; + + //delete mProfile; + mAllprofiles.ResetAndDestroy(); + mAllprofiles.Close(); + + delete mProfileReg; + delete mSip; + delete mOriginatorUri; + + } + +void ChatContactManagerImpl::closeSession(RcsChatId sessID) +{ + + CMceSession *currentSession = reinterpret_cast(sessID); + + int mSessionState = currentSession->State(); + + if (mSessionState == CMceSession::EEstablished) + currentSession->TerminateL(); + + //remove and close + + TInt idx = mMceSessions.Find(currentSession); + if (idx != KErrNotFound) + { + delete currentSession; + mMceSessions.Remove(idx); + } + + for(int i=0;iiMceSession == currentSession) + { + delete mChatSessionArray[i]; + mChatSessionArray.Remove(i); + break; + } + } + } + +void ChatContactManagerImpl::acceptIncomingSession(RcsChatId sessID) +{ + CMceInSession *currentSession = reinterpret_cast(sessID); + if (currentSession->State() == CMceSession::EProceeding) + { + currentSession->AcceptL(); + } + } + + + +RcsIMLib::RcsChatId ChatContactManagerImpl::createChatSession(QContactLocalId contactId, QString initMsg) +{ + RcsIMLib::RcsChatId id = 0; + QT_TRAP_THROWING(id = createChatSessionL(contactId, initMsg)); + //QT_TRYCATCH_ERROR(id = createChatSessionL(contactId, initMsg)); + return id; +} + + +RcsIMLib::RcsChatId ChatContactManagerImpl::createChatSessionL(QContactLocalId contactId, QString initMsg) +{ + // To get recipient SIP Uri. + const QContact buddy = mManager->contact(contactId); + QContactDetail buddyContactDetail = buddy.detail(QContactOnlineAccount::DefinitionName); + const QContactOnlineAccount &onlineUrl = static_cast(buddyContactDetail); + QString buddySipUri = onlineUrl.accountUri(); + TPtrC16 dataPtr(reinterpret_cast(buddySipUri.utf16())); + HBufC8 *recipientUri = HBufC8::NewL(dataPtr.Length()); + CleanupStack::PushL(recipientUri); + recipientUri->Des().Copy(dataPtr); + + CMceOutSession *outSess ; + if(mProfile) + { + outSess = CMceOutSession::NewL(*mMceMgr, *mProfile, *recipientUri); + } + else + { + outSess = CMceOutSession::NewL(*mMceMgr, 1,*mOriginatorUri, *recipientUri); + } + CleanupStack::PopAndDestroy(recipientUri); + CleanupStack::PushL(outSess); + + /* Add the out session to the list of MCESessions */ + mMceSessions.Append(outSess); + CleanupStack::Pop(outSess); + + /* Streams Creation */ + // Create the stream for UpLink and Downlink + CMceMessageStream* msgStrmUp = CMceMessageStream::NewL(); + CleanupStack::PushL(msgStrmUp); + + // Message Source + CMceMessageSource* messageSrc = CMceMessageSource::NewL(*mMceMgr); + CleanupStack::PushL(messageSrc); + + //MSRP Sink + CMceMsrpSink* msrpSink = CMceMsrpSink::NewL(); + CleanupStack::Pop(messageSrc); + CleanupStack::PushL(msrpSink); + CleanupStack::PushL(messageSrc); + msgStrmUp->SetSourceL(messageSrc); + CleanupStack::Pop(messageSrc); + + // Add sink to the stream + msgStrmUp->AddSinkL(msrpSink); + CleanupStack::Pop(msrpSink); + msgStrmUp->ConnectionSetUpL(CMceMessageStream::EActive); + + // Set AcceptTypes + CDesC8ArrayFlat *acceptTypes = new(ELeave)CDesC8ArrayFlat(KGranularity); + _LIT8(KtextPlain,"text/plain"); + acceptTypes->AppendL(KtextPlain); + + msrpSink->SetAcceptTypesL(*acceptTypes); + delete acceptTypes; + + _LIT8(KAcceptWrap, "acceptwrap"); + TBuf8 accept(KAcceptWrap); + msrpSink->SetAcceptWrappedTypesL(accept); + + + //outSess->AddStreamL(msgStrmUp); + CleanupStack::Pop(msgStrmUp); + + + // Create the stream for Downlink + CMceMessageStream *msgStrmDown = CMceMessageStream::NewL(); + + // MSRP Source + CMceMsrpSource *msrpSrc = CMceMsrpSource::NewL(); + + // Message Sink + CMceMessageSink* messageSink = CMceMessageSink::NewL(*mMceMgr); + CleanupStack::PushL(msrpSrc); + msgStrmDown->SetSourceL(msrpSrc); + CleanupStack::Pop(msrpSrc); + + // Add sink to the stream + CleanupStack::PushL(messageSink); + msgStrmDown->AddSinkL(messageSink); + CleanupStack::Pop(messageSink); + msgStrmDown->ConnectionSetUpL(CMceMessageStream::EActive); + + CleanupStack::PushL(msgStrmUp); + msgStrmDown->BindL(msgStrmUp); + CleanupStack::Pop(msgStrmUp); + + CleanupStack::PushL(msgStrmDown); + outSess->AddStreamL(msgStrmDown); + CleanupStack::Pop(msgStrmDown); + + /* A new Chat Session with the Platform specific Init Params */ + ChatSession *chatSession = new ChatSession(); + + /* Create the ChatSession here */ + TMsrpChatSession *msrpChatSession = new TMsrpChatSession(); + msrpChatSession->iMceManager = mMceMgr; + msrpChatSession->iMceSession = outSess; + msrpChatSession->iChatSession = chatSession; + msrpChatSession->iStream1 = msgStrmUp; + msrpChatSession->iStream2 = msgStrmDown; + + //chatSession->setPlatformParams(msrpChatSession); + + mChatSessionArray.Append(msrpChatSession); + + + //Start the session establishment here. Emit the signal when everything is + //done. The session will be matched my the ID returned. + //RcsChatId sessID = (RcsChatId)&outSess; + + + //Create the CDesC8Array with the syntax of the subject header and pass it + //such that the INVITE is constructed with Subject header. + + CDesC8ArrayFlat *mSIPHeaders = new CDesC8ArrayFlat(20); + QString mSubjectHeader = "Subject:"+ initMsg; + TPtrC16 mDataPtr(reinterpret_cast(mSubjectHeader.utf16())); + RBuf8 mChatData; + mChatData.Create(300); + mChatData.Copy(mDataPtr); + + mSIPHeaders->AppendL(mChatData); + outSess->EstablishL(0,mSIPHeaders,0,0,0); + + return reinterpret_cast(outSess); +} + +void ChatContactManagerImpl::setupMceManagerL() +{ + //RFileLogger::Write( KLogDir1, KLogFile1, EFileLoggingModeAppend, _L("setupMceManagerL ChkPt 0") ); + //Setup MCE For accepting and receiving chat messages + mMceMgr = CMceManager::NewL(TUid::Uid(0x10009388), &mDataContainer); + + // Set session observer to get the session related state changes + mMceMgr->SetSessionObserver(this); + + // Set InSession Observer to recieve the incoming session + mMceMgr->SetInSessionObserver(this); + mMceMgr->SetDataSinkObserver(this); + + TUid appUid; + + appUid.iUid = 0xA00001EC; //TODO get APPUID Correct + TRAPD(errsip, mSip = CSIP::NewL(appUid , *this)) + //TRAPD(errsip, mSip = CSIP::NewL(TUid::Null(), *this)) + if (!errsip) { + //CleanupStack::PushL(sipClient); + mProfileReg = CSIPProfileRegistry::NewL(*mSip, *this); + //CleanupStack::Pop(mSip); + } + + //assumes first profile is registered and valid + //CleanupStack::PushL(profileReg); + //mProfile = profileReg->DefaultProfileL(); + + + //later check for tag matches + + + mProfileReg->ProfilesL(mAllprofiles); + if (mAllprofiles.Count()) + { + mProfile = mAllprofiles[0]; + } + + //CleanupStack::PopAndDestroy(profileReg); + //CleanupStack::PopAndDestroy(sipClient); +} + + +void ChatContactManagerImpl::SessionStateChanged( CMceSession& aSession, TMceTransactionDataContainer* aContainer) +{ + if (aSession.State() == CMceSession::EEstablished) + { + + CMceMessageStream* downlinkStr = NULL; + CMceMessageStream* uplinkStr = NULL; + + GetStreams(aSession, uplinkStr, downlinkStr ); + + if (uplinkStr && uplinkStr->Source() && + uplinkStr->Source()->Type() == KMceMessageSource) + { + uplinkStr->Source()->DisableL(); + if (!uplinkStr->Source()->IsEnabled()) + uplinkStr->Source()->EnableL(); + } + + if (downlinkStr && downlinkStr->Sinks().Count() > 0) + { + // assume only one sink is added + downlinkStr->Sinks()[0]->DisableL(); + if (! downlinkStr->Sinks()[0]->IsEnabled() ) + downlinkStr->Sinks()[0]->EnableL(); + } + + for(int i=0;iiMceSession == &aSession) + { + mChatSessionArray[i]->iStream1 = uplinkStr; + mChatSessionArray[i]->iStream2 = downlinkStr; + mChatSessionArray[i]->iChatSession->setPlatformParams(mChatSessionArray[i]); + break; + } + } + + +/* //can be terminated without establishment + // A new Chat Session with the Platform specific Init Params + ChatSession *chatSession = new ChatSession(); + + //Create the ChatSession here + TMsrpChatSession *msrpChatSession = new TMsrpChatSession(); + msrpChatSession->iMceManager = mMceMgr; + msrpChatSession->iMceSession = &aSession; + msrpChatSession->iChatSession = chatSession; + msrpChatSession->iStream1 = uplinkStr; + msrpChatSession->iStream2 = downlinkStr; + + chatSession->setPlatformParams(msrpChatSession); + + mChatSessionArray.Append(msrpChatSession); +*/ + + /* Notify the UI that Session is established. Pointer to aSession + * serves as the key */ + for(int i=0;iiMceSession == &aSession) + { + emit mParent->sessionEstablised(reinterpret_cast(&aSession), mChatSessionArray[i]->iChatSession); + break; + } + } + + + } + else if (aSession.State() == CMceSession::EProceeding) + { + //get originator + const TDesC8& remoteURI = aSession.Originator(); + const QString remoteSIPURI = QString::fromUtf8((const char*)remoteURI.Ptr(),remoteURI.Length()); + + //Pass the remote sip uri as a filter and fetch the buddy name. + //Also emit a signal here for incomingChatSession with the contactID + + // To fetch the buddy name using the sip URI. + QList order; + QStringList list; + QContactDetailFilter filter; + filter.setDetailDefinitionName(QContactOnlineAccount::DefinitionName, QContactOnlineAccount::SubTypeSip); + filter.setValue(remoteSIPURI); + + QList allContacts; + allContacts = mManager->contacts(filter); + unsigned int buddyID = 0; + if(allContacts.count()) + { + buddyID = allContacts[0].localId(); + } + + QString imMsg; + + + for(int i=0;iiMceSession == &aSession) + { + imMsg = mChatSessionArray[i]->iInitMsg; + break; + } + } + + + //emit on SSC to proceeding as a result of call to updateL //see insession header + //emit after update or could lead to accept call before update, little chance as user interaction involved + emit mParent->incomingChatSession(buddyID, remoteSIPURI, imMsg, reinterpret_cast(&aSession)); + } + else if (aSession.State() == CMceSession::ETerminated) + { + for(int i=0;iiMceSession == &aSession) + { + emit mParent->sessionTerminated(reinterpret_cast(&aSession), mChatSessionArray[i]->iChatSession); + break; + } + } + + } +} + + + +void ChatContactManagerImpl::SessionConnectionStateChanged( CMceSession& , TBool /*aActive*/ ) +{ +} + +void ChatContactManagerImpl::Failed( CMceSession& /*aSession*/, TInt /*aError*/ ) +{ +} + +void ChatContactManagerImpl::UpdateFailed(CMceSession& /*aSession*/, TMceTransactionDataContainer* /*aContainer*/ ) +{ +} + +// From MSIPProfileAgentObserver +void ChatContactManagerImpl::ProfileRegistryEventOccurred(TUint32 /*aProfileId*/, TEvent /*aEvent*/) +{ +} + +void ChatContactManagerImpl::ProfileRegistryErrorOccurred(TUint32 /*aProfileId*/, TInt /*aError*/) +{ +} + +// From MSIPObserver +void ChatContactManagerImpl::IncomingRequest(TUint32 /*aIapId*/, CSIPServerTransaction* /*aTransaction*/) +{ +} + +void ChatContactManagerImpl::TimedOut(CSIPServerTransaction& /*aTransaction*/) +{ +} + +// From MMceInSessionObserver +void ChatContactManagerImpl::IncomingSession(CMceInSession* aSession, TMceTransactionDataContainer* aContainer ) +{ + if (aSession->State() == CMceSession::EIncoming) + { + /////////////////////// + QString imMsg; + //Fetch the message from the SIP INVITE + CDesC8Array *mSIPHeader = aContainer->GetHeaders(); + TInt count = mSIPHeader->MdcaCount(); + + for (int i=0; iMdcaPoint(i); + QString header = QString::fromUtf8((const char*)data.Ptr(),data.Length()); + if (header.contains("Subject",Qt::CaseSensitive)) + { + QChar sep = ':'; + //QString mChatData = header.section(sep,1); + imMsg = header.section(sep,1); + } + else + { + //QString mChatData = ""; + imMsg = ""; + } + } + ////////////////////// + + // get the stream for this incoming session to set the MSRP capabilities + CMceMessageStream* downlinkStr = NULL; + CMceMessageStream* uplinkStr = NULL; + GetStreams(*aSession, uplinkStr, downlinkStr); + + ChatSession *chatSession = new ChatSession(); + + // Create the ChatSession here + TMsrpChatSession *msrpChatSession = new TMsrpChatSession(); + msrpChatSession->iMceManager = mMceMgr; + msrpChatSession->iMceSession = aSession; + msrpChatSession->iChatSession = chatSession; + msrpChatSession->iStream1 = uplinkStr; + msrpChatSession->iStream2 = downlinkStr; + msrpChatSession->iInitMsg = imMsg; + + mChatSessionArray.Append(msrpChatSession); + + + if (downlinkStr ) + { + CMceMsrpSource* msrpSource = static_cast (downlinkStr->Source()); + if(msrpSource) + { + downlinkStr->ConnectionSetUpL(CMceMessageStream::EPassive); + //uplinkStr->ConnectionSetUpL(CMceMessageStream::EPassive); + + // Set AcceptTypes + CDesC8ArrayFlat *acceptTypes = new(ELeave)CDesC8ArrayFlat(KGranularity); + _LIT8(KtextPlain,"text/plain"); + _LIT8(KMessageCpim, "message/cpim"); + acceptTypes->AppendL(KtextPlain); + acceptTypes->AppendL(KMessageCpim); + + msrpSource->SetAcceptTypesL(*acceptTypes); + delete acceptTypes; + + _LIT8(KAcceptWrap, "acceptwrap"); + TBuf8 accept(KAcceptWrap); + msrpSource->SetAcceptWrappedTypesL(accept); + } + } + + /* Add the out session to the list of MCESessions */ + mMceSessions.Append(aSession); + aSession->UpdateL(); + } +} + + +void ChatContactManagerImpl::IncomingUpdate(CMceSession& , CMceInSession* , TMceTransactionDataContainer* ) +{ +} + +void ChatContactManagerImpl::DataReceived(CMceMediaStream& aStream, CMceMediaSink& /*aSink*/, const TDesC8& aData) +{ + /* Find the Session for which this Message is intented */ + for(int i=0; iiStream1 == &aStream || mChatSessionArray[i]->iStream2 == &aStream) + { + ChatSessionImpl *pImpl = static_cast(mChatSessionArray[i]->iChatSession->getPlatformImpl()); + pImpl->incomingData(aData); + } + } +} + + +void ChatContactManagerImpl::GetStreams(CMceSession& aSession, CMceMessageStream*& aUplinkStr, CMceMessageStream*& aDownlinkStr ) + { + RPointerArray streams = aSession.Streams(); + for (TInt i=0; iType() == KMceMessage && + streams[i]->Source() && + streams[i]->Source()->Type() == KMceMSRPSource) + { + aDownlinkStr =static_cast (streams[i]); + //break; + } + + if (streams[i]->Type() == KMceMessage && + streams[i]->Source() && + streams[i]->Source()->Type() == KMceMessageSource) + { + aUplinkStr =static_cast (streams[i]); + //break; + } + if (aDownlinkStr == NULL && streams[i]->BoundStream()) + { + if (streams[i]->BoundStreamL().Type() == KMceMessage && + streams[i]->BoundStreamL().Source() && + streams[i]->BoundStreamL().Source()->Type() == KMceMSRPSource) + { + CMceMessageStream& stream =static_cast (streams[i]->BoundStreamL()); + aDownlinkStr = &stream; + // break; + } + } + + if (aUplinkStr == NULL && streams[i]->BoundStream()) + { + if (streams[i]->BoundStreamL().Type() == KMceMessage && + streams[i]->BoundStreamL().Source() && + streams[i]->BoundStreamL().Source()->Type() == KMceMessageSource) + { + CMceMessageStream& stream =static_cast (streams[i]->BoundStreamL()); + aUplinkStr = &stream; + } + } + } // for loop + + } + + + diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/src/chatsession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/src/chatsession.cpp Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#include "chatsession.h" +#ifdef Q_OS_SYMBIAN +#include "chatsessionimpl_sym.h" +#endif + +using namespace RcsIMLib; + +ChatSession::ChatSession() +{ + mpImpl = new ChatSessionImpl(this); +} + +bool ChatSession::endChatSession() +{ + return mpImpl->endChatSession(); +} + +bool ChatSession::sendChatData(QString newChatData) +{ + return mpImpl->sendChatData(newChatData); +} + +void ChatSession::setPlatformParams(void *apPlatFormParam) +{ + mpImpl->setPlatformParams(apPlatFormParam); +} + +//Get the Platform implementations +void* ChatSession::getPlatformImpl() +{ + return mpImpl->getPlatformImpl(); +} diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/src/chatsessionimpl_sym.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/src/chatsessionimpl_sym.cpp Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#include +#include + +#include +#include + +#include +#include + +#include "chatsessionimpl_sym.h" +#include "msrpchatsessiondata_sym.h" + +using namespace RcsIMLib; + +//_LIT( KLogDir1, "rcs" ); +//_LIT( KLogFile1, "rcs.txt" ); + + + +ChatSessionImpl::ChatSessionImpl(ChatSession *apParent):mParent(apParent) +{ + +} + +bool ChatSessionImpl::sendChatData(QString newChatData) +{ + TPtrC16 dataPtr(reinterpret_cast(newChatData.utf16())); + RBuf8 chatData; + chatData.Create(300); + chatData.Copy(dataPtr); + + mMessageSource->SendDataL(chatData); + + chatData.Close(); + + return true; +} + + +bool ChatSessionImpl::endChatSession() +{ + return true; +} + +void ChatSessionImpl::setPlatformParams(void *apPlatFormParam) +{ + mMsrpChatSessionData = static_cast(apPlatFormParam); + if (mMsrpChatSessionData->iStream1->Source()->Type() == KMceMessageSource) + { + mMessageSource = (CMceMessageSource*) mMsrpChatSessionData->iStream1->Source(); + } + else if (mMsrpChatSessionData->iStream2->Source()->Type() == KMceMessageSource) + { + mMessageSource = (CMceMessageSource*) mMsrpChatSessionData->iStream2->Source(); + } +} + +//Get the Platform implementations +void* ChatSessionImpl::getPlatformImpl() +{ + return this; +} + +void ChatSessionImpl::incomingData(const TDesC8& aData) +{ + QString chatData = QString::fromUtf8((const char*)aData.Ptr(),aData.Length()); + emit mParent->newChatData(chatData); +} diff -r 000000000000 -r 59dfe4ae66d0 rcsimengine/src/rcsimmanagerfactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rcsimengine/src/rcsimmanagerfactory.cpp Fri Oct 08 18:07:26 2010 +0530 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html." +* Initial Contributors: +* Nokia Corporation - initial contribution. +* Contributors: +* +* Description: +* RCS IM Library - Initial version +* +*/ + + +#include "rcsimmanagerfactory.h" +#include "chatinterfaces.h" +#include "chatcontactmanager.h" + +using namespace RcsIMLib; + +RcsIMLib::MChatContactManagerIntf* RcsIMManagerFactory::createIMManager() +{ + return new ChatContactManager(); +} + +QString RcsIMManagerFactory::protocol() +{ + return "rcsmsrp"; +} + +Q_EXPORT_PLUGIN2(symmsrpplugin, RcsIMManagerFactory) + +//static const char *qt_plugin_verification_data = \ +// "pattern=""QT_PLUGIN_VERIFICATION_DATA""\n" \ +// "version=""4.6.3""\n" \ +// "debug=""false""\n" \ +// "buildkey=""Symbian full-config"; \ +// extern "C" __declspec(dllexport) \ +// const char * qt_plugin_query_verification_data() \ +// { return qt_plugin_verification_data; } \ +// extern "C" __declspec(dllexport) ::QObject * qt_plugin_instance() \ +// { \ +// static QPointer _instance; \ +// if (!_instance) \ +// _instance = new RcsIMManagerFactory; \ +// return _instance; \ +// } +