|
1 /* |
|
2 * Copyright (c) 2008 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 #ifndef SERVERCONNECTIONBASE_H |
|
19 #define SERVERCONNECTIONBASE_H |
|
20 |
|
21 #include "serverconnection.h" |
|
22 #include "javasmsattributes.h" |
|
23 |
|
24 |
|
25 namespace java |
|
26 { |
|
27 namespace wma |
|
28 { |
|
29 /** |
|
30 * ServerConnectionBase abstract class extends interface ServerConnection. |
|
31 * It defines the interfaces that are to be implemented by the corresponding |
|
32 * protocol ServerConnection class. |
|
33 * |
|
34 * @smsserverconnection.dll |
|
35 * @ |
|
36 */ |
|
37 |
|
38 class ServerConnectionBase: public java::push::ServerConnection |
|
39 { |
|
40 |
|
41 public: |
|
42 /** |
|
43 * factory method to create the server connection |
|
44 * @param[in] aUri - uri on which the server connection to be opened |
|
45 * @param[in] aFilter - filter to allow messages to be received from |
|
46 * desired sender. |
|
47 * @return ServerConnection |
|
48 */ |
|
49 static ServerConnection* getServerConnection(const std::wstring& aUri, |
|
50 const std::wstring& aFilter); |
|
51 |
|
52 virtual ~ServerConnectionBase() |
|
53 { |
|
54 |
|
55 } |
|
56 /** |
|
57 * Opens the connection. It registers the server URI to the messaging system |
|
58 * for receiving messages. |
|
59 * Throws COMMON_SRV_CONN_PLUGIN_ERROR exception if there is an error while |
|
60 * registering the connection. |
|
61 * @param[in] aListener: Listener to be notified when message arrives. |
|
62 * @param[in] aAppLaunched : bool to notify listening by midlet or push. |
|
63 */ |
|
64 OS_IMPORT virtual void open(java::push::ConnectionListener* aListener, |
|
65 bool aAppLaunched) =0; |
|
66 /** |
|
67 * from ServerConnection |
|
68 * Return the push register URI |
|
69 * @return uri as std::wstring |
|
70 */ |
|
71 OS_IMPORT virtual std::wstring getUri() const; |
|
72 /** |
|
73 * from ServerConnection |
|
74 * Sets the Filter |
|
75 * @param aFilter - filter which defines the acceptable messages |
|
76 * @return |
|
77 */ |
|
78 OS_IMPORT virtual void setFilter(const std::wstring& aFilter); |
|
79 /** |
|
80 * from ServerConnection |
|
81 * Return the filter string |
|
82 * @return std::wstring |
|
83 */ |
|
84 OS_IMPORT virtual std::wstring getFilter() const; |
|
85 /** |
|
86 * Return the number of messages that have arrived and to be read by the |
|
87 * application. |
|
88 * @return int - number of messages that needs to be read by application |
|
89 */ |
|
90 OS_IMPORT int getMessagesOnStore() const; |
|
91 /** |
|
92 * retrieves the received message |
|
93 * @param[out] aSmsBuf:the message buffer into which the received message is |
|
94 * written into. |
|
95 * @return SUCCESS or FAILURE status |
|
96 */ |
|
97 virtual int retrieveMessage(TJavaMessageParametersBuf& aSmsBuf)=0; |
|
98 protected: |
|
99 //Constructor |
|
100 ServerConnectionBase(const std::wstring& aUri, const std::wstring& aFilter); |
|
101 /** |
|
102 * Deletes a message on store. |
|
103 */ |
|
104 void deleteMessage(); |
|
105 |
|
106 /** |
|
107 * Creates a Message store , to save incoming messages |
|
108 * so that the application can read the message from the store. |
|
109 * @param path:the message store path |
|
110 * @returns SUCCESS or FAILURE |
|
111 */ |
|
112 int createMessageStore(std::wstring aPath); |
|
113 |
|
114 /** |
|
115 * Removes the directory specified. |
|
116 * @param dirPath: the directory that has to be removed |
|
117 * @returns SUCCESS or FAILURE |
|
118 */ |
|
119 int removeDir(const std::wstring aDirPath); |
|
120 /** |
|
121 * Creates the specified directory if it doesn't exists . |
|
122 * @param dirPath the directory path |
|
123 * @returns SUCCESS or FAILURE |
|
124 */ |
|
125 int makeDirAll(const std::wstring aDirPath); |
|
126 |
|
127 protected: |
|
128 // Flag to indicate whether the server connection is opened by push or by |
|
129 // application; |
|
130 bool mIsAppLaunched; |
|
131 // Flag to indicate whether listening or not |
|
132 bool mIsListening; |
|
133 //port on which the push connection is opened |
|
134 int mPort; |
|
135 // Uri of the push connection |
|
136 std::wstring mUri; |
|
137 //Filter |
|
138 std::wstring mFilter; |
|
139 //the number of messages in store |
|
140 int mMessagesOnStore; |
|
141 //next message to be stored |
|
142 int mNextMessageInStore; |
|
143 //first message in store |
|
144 int mFirstMessageInStore; |
|
145 //message store |
|
146 std::wstring mMessageStoreDirName; |
|
147 }; |
|
148 |
|
149 }// end of namespace wma |
|
150 }// end of namespace java |
|
151 #endif // SERVERCONNECTIONBASE_H |
|
152 |