|
0
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2004 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_SESSION_H
|
|
|
20 |
#define MSG_SESSION_H
|
|
|
21 |
|
|
|
22 |
#include <e32std.h>
|
|
|
23 |
#include "MsgTypes.h"
|
|
|
24 |
|
|
|
25 |
class CMessageListener;
|
|
|
26 |
class CMessageNotifier;
|
|
|
27 |
|
|
|
28 |
class CMessageSession : public RSessionBase
|
|
|
29 |
{
|
|
|
30 |
friend class CMessageNotifier;
|
|
|
31 |
|
|
|
32 |
/* Request status for notifying incoming messages. */
|
|
|
33 |
CMessageNotifier *iIncomingNotify;
|
|
|
34 |
|
|
|
35 |
CMessageListener *iListener;
|
|
|
36 |
|
|
|
37 |
/* Message buffer for new messages. */
|
|
|
38 |
HBufC8 *iMessageBuffer;
|
|
|
39 |
TPtr8 *iMessagePtr;
|
|
|
40 |
|
|
|
41 |
IMPORT_C void ConstructL();
|
|
|
42 |
|
|
|
43 |
IMPORT_C CMessageSession();
|
|
|
44 |
public:
|
|
|
45 |
|
|
|
46 |
IMPORT_C static CMessageSession *NewL();
|
|
|
47 |
IMPORT_C static CMessageSession *NewLC();
|
|
|
48 |
|
|
|
49 |
IMPORT_C ~CMessageSession();
|
|
|
50 |
|
|
|
51 |
/* Attaches to server. */
|
|
|
52 |
IMPORT_C void AttachL();
|
|
|
53 |
|
|
|
54 |
/* Sends a message. */
|
|
|
55 |
IMPORT_C void SendMessageL(const TPtr8 &aMessage, TMessageType aType);
|
|
|
56 |
|
|
|
57 |
/* Listen messages of given type in a given port. One
|
|
|
58 |
session may listen to one port only.
|
|
|
59 |
Message listener MUST be set before calling ListenMessageL(...).
|
|
|
60 |
Only one type/port may be listened at a time. */
|
|
|
61 |
IMPORT_C void ListenMessagesL(TMessageType aType, TUint aPort);
|
|
|
62 |
|
|
|
63 |
/* Stops listening message. */
|
|
|
64 |
IMPORT_C void StopListeningL();
|
|
|
65 |
|
|
|
66 |
/* Sets the message listener. Listener's ReceiveMessageL(...)
|
|
|
67 |
is called, when a new message is received. */
|
|
|
68 |
IMPORT_C void SetListener(CMessageListener *aListener);
|
|
|
69 |
|
|
|
70 |
/* Returns ETrue, is session set to listening state. */
|
|
|
71 |
IMPORT_C TBool IsListening() const;
|
|
|
72 |
|
|
|
73 |
/* Returns ETrue, if file based SMS should be used.
|
|
|
74 |
Reads the settings from c:\system\data\wma.ini file.
|
|
|
75 |
File format:
|
|
|
76 |
# Starts a comment line
|
|
|
77 |
# Set UseSocketOutput=1 to use native sockets implementation,
|
|
|
78 |
# UseSocketOutput=0 to use file based SMS messaging.
|
|
|
79 |
UseSocketOutput=0 */
|
|
|
80 |
IMPORT_C static TBool UseFileSMS();
|
|
|
81 |
};
|
|
|
82 |
|
|
|
83 |
class CMessageListener
|
|
|
84 |
{
|
|
|
85 |
|
|
|
86 |
protected:
|
|
|
87 |
|
|
|
88 |
IMPORT_C void ConstructL();
|
|
|
89 |
|
|
|
90 |
public:
|
|
|
91 |
|
|
|
92 |
IMPORT_C static CMessageListener *NewL();
|
|
|
93 |
IMPORT_C static CMessageListener *NewLC();
|
|
|
94 |
|
|
|
95 |
IMPORT_C virtual ~CMessageListener();
|
|
|
96 |
|
|
|
97 |
/* Called when a message is received. */
|
|
|
98 |
IMPORT_C virtual void ReceiveMessageL(const TPtr8 &aMessage);
|
|
|
99 |
};
|
|
|
100 |
|
|
|
101 |
#endif /* MSG_SESSION_H */ |