|
0
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
* This component and the accompanying materials are made available
|
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
|
6 |
* which accompanies this distribution, and is available
|
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
|
8 |
*
|
|
|
9 |
* Initial Contributors:
|
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
|
11 |
*
|
|
|
12 |
* Contributors:
|
|
|
13 |
*
|
|
|
14 |
* Description:
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
#ifndef MSG_RELAY_H
|
|
|
20 |
#define MSG_RELAY_H
|
|
|
21 |
|
|
|
22 |
#include <e32std.h>
|
|
|
23 |
#include <e32base.h>
|
|
|
24 |
#include <msvapi.h>
|
|
|
25 |
#include "MsgTypes.h"
|
|
|
26 |
|
|
|
27 |
class CMessageWriter;
|
|
|
28 |
class CRelaySession;
|
|
|
29 |
|
|
|
30 |
class CMessageRelay : public CServer2, public MMsvSessionObserver
|
|
|
31 |
{
|
|
|
32 |
friend class CRelaySession;
|
|
|
33 |
|
|
|
34 |
CArrayFixFlat<CRelaySession *> *iSessions;
|
|
|
35 |
CMessageWriter *iWriter;
|
|
|
36 |
|
|
|
37 |
CSession2* NewSessionL(const TVersion& aVersion) const;
|
|
|
38 |
CSession2* NewSessionL(const TVersion& aVersion, const RMessage2&) const;
|
|
|
39 |
|
|
|
40 |
/* Goes through all sessions and returns ETrue, is someone
|
|
|
41 |
is listening the given port. */
|
|
|
42 |
TBool IsAnyBodyListening(TUint aPort, TMessageType aType);
|
|
|
43 |
|
|
|
44 |
/* Copies the message to inbox. */
|
|
|
45 |
void CopyMessageToSmsInboxL(TPtr8 &aMessage);
|
|
|
46 |
|
|
|
47 |
/* Traverses the inbox and sends messages to listeners. */
|
|
|
48 |
void TraverseInboxL();
|
|
|
49 |
|
|
|
50 |
protected:
|
|
|
51 |
|
|
|
52 |
IMPORT_C CMessageRelay();
|
|
|
53 |
IMPORT_C void ConstructL(CMessageWriter *aWriter);
|
|
|
54 |
|
|
|
55 |
public:
|
|
|
56 |
|
|
|
57 |
IMPORT_C static CMessageRelay *NewL(CMessageWriter *aWriter = NULL);
|
|
|
58 |
IMPORT_C static CMessageRelay *NewLC(CMessageWriter *aWriter = NULL);
|
|
|
59 |
|
|
|
60 |
IMPORT_C ~CMessageRelay();
|
|
|
61 |
|
|
|
62 |
/* Starts the server. */
|
|
|
63 |
IMPORT_C void StartRelayL();
|
|
|
64 |
|
|
|
65 |
/* Call this method when a new message is received to relay it
|
|
|
66 |
to possible listeners. Returns ETrue, if the message was
|
|
|
67 |
accepted. If the message as not accepted, it must not be
|
|
|
68 |
destroyed, but it must be offered again, as soon as there
|
|
|
69 |
is a listener for it. */
|
|
|
70 |
IMPORT_C TBool NewMessageL(TPtr8 &aMessage, TMessageType aType);
|
|
|
71 |
|
|
|
72 |
/* Sets the message writer. Writers WriteMessageL(...) method
|
|
|
73 |
is called when a client wants to send a message. */
|
|
|
74 |
IMPORT_C void SetWriter(CMessageWriter *aWriter);
|
|
|
75 |
|
|
|
76 |
void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,
|
|
|
77 |
TAny* aArg2, TAny* aArg3);
|
|
|
78 |
|
|
|
79 |
};
|
|
|
80 |
|
|
|
81 |
class CMessageWriter
|
|
|
82 |
{
|
|
|
83 |
|
|
|
84 |
IMPORT_C void ConstructL();
|
|
|
85 |
|
|
|
86 |
public:
|
|
|
87 |
|
|
|
88 |
IMPORT_C static CMessageWriter *NewL();
|
|
|
89 |
IMPORT_C static CMessageWriter *NewLC();
|
|
|
90 |
|
|
|
91 |
IMPORT_C virtual ~CMessageWriter();
|
|
|
92 |
|
|
|
93 |
/* Called when a message is received from client for sending. */
|
|
|
94 |
IMPORT_C virtual void WriteMessageL(TPtr8 &aMessage, TMessageType aType);
|
|
|
95 |
};
|
|
|
96 |
|
|
|
97 |
#endif /* MSG_RELAY_H */
|