javaextensions/bluetooth/bluetoothplugins/btl2cappushplugin/inc/btl2cappushserverconnection.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     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 
       
    19 #ifndef BTL2CAPPUSHSERVERCONNECTION_H
       
    20 #define BTL2CAPPUSHSERVERCONNECTION_H
       
    21 
       
    22 #include <string>
       
    23 #include <dirent.h>
       
    24 #include <sys/types.h>
       
    25 
       
    26 #include "logger.h"
       
    27 #include "javaoslayer.h"
       
    28 #include "javacommonutils.h"
       
    29 
       
    30 #include "serverconnection.h"
       
    31 #include "connectionlistener.h"
       
    32 
       
    33 #include "bluetoothfunctionserver.h"
       
    34 #include "bluetoothpusheventlistener.h"
       
    35 #include "bluetoothclientconnection.h"
       
    36 #include "btl2capserverconnection.h"
       
    37 
       
    38 #include "bturlparams.h"
       
    39 
       
    40 namespace java
       
    41 {
       
    42 namespace bluetooth
       
    43 {
       
    44 
       
    45 /**
       
    46  * L2CapPushServerConnection implements ServerConnection. Used by Push framework.
       
    47  *
       
    48  */
       
    49 class L2CapPushServerConnection: public java::push::ServerConnection,
       
    50         public BluetoothPushEventListener
       
    51 {
       
    52 
       
    53 public:
       
    54     OS_IMPORT L2CapPushServerConnection(const std::wstring aUri,
       
    55                                         const std::wstring aFilter);
       
    56 
       
    57     OS_IMPORT virtual ~L2CapPushServerConnection();
       
    58 
       
    59     /**
       
    60      * This operation opens physical protocol connection.
       
    61      * @param aListener This operation does not take ownership of this pointer.
       
    62      * @throws PushException with COMMON_SRV_CONN_PLUGIN_ERROR error code if
       
    63      *         creation of the connection fails.
       
    64      */
       
    65     OS_IMPORT virtual void open(java::push::ConnectionListener* aListener);
       
    66 
       
    67     /**
       
    68      * This operation closes physical protocol connection.
       
    69      * This operation does not throw an exception.
       
    70      */
       
    71     OS_IMPORT virtual void close();
       
    72 
       
    73     /**
       
    74      * @return connection URI.
       
    75      */
       
    76     OS_IMPORT virtual std::wstring getUri() const;
       
    77 
       
    78     /**
       
    79      * @return filter URI of the push connection. Empty string is returned in the normal
       
    80      *         ServerConnection case.
       
    81      */
       
    82     OS_IMPORT virtual std::wstring getFilter() const;
       
    83 
       
    84     /**
       
    85      * Sets 'filter' argument for the connection. This method is needed in the situation where
       
    86      * 'normal' ServerConnection has been created before dynamic push registration.
       
    87      */
       
    88     OS_IMPORT virtual void setFilter(const std::wstring& aFilter);
       
    89 
       
    90     virtual void handleConnectionRequest(
       
    91         BluetoothClientConnection* aClientConnection, TInt err);
       
    92 
       
    93     OS_IMPORT bool isActive();
       
    94 
       
    95     OS_IMPORT bool isConnectionAccepted();
       
    96 
       
    97     OS_IMPORT bool isListening();
       
    98 
       
    99     OS_IMPORT bool isCreatedByPush();
       
   100 
       
   101     OS_IMPORT L2CAPServerConnection* getServerObject();
       
   102 
       
   103     OS_IMPORT void deleteServer();
       
   104 
       
   105     OS_IMPORT BluetoothClientConnection* getConnectedClient();
       
   106 
       
   107     OS_IMPORT void setAcceptMonitor(java::util::Monitor* aMonitor);
       
   108 
       
   109     OS_IMPORT void setCreatedByPush();
       
   110 
       
   111     OS_IMPORT void unsetAcceptMonitor();
       
   112 
       
   113     OS_IMPORT void unsetClearServiceClassBitsFlag();
       
   114 
       
   115 private:
       
   116     java::util::Monitor* mAcceptMonitor;
       
   117 
       
   118     java::push::ConnectionListener* mConnectionListener;
       
   119 
       
   120     std::wstring mConnectionUri;
       
   121 
       
   122     std::wstring mConnectionFilter;
       
   123 
       
   124     // Holds the URL/Filter parameters
       
   125     BtUrlParams* mBtUrlParams;
       
   126 
       
   127     // Bluetooth Function Server. To be used for async calls.
       
   128     BluetoothFunctionServer* mFunctionServer;
       
   129 
       
   130     // Reference to Server object.
       
   131     L2CAPServerConnection* mL2CAPServer;
       
   132 
       
   133     // Holds reference to Client connection on successful push invocation.
       
   134     BluetoothClientConnection* mClientConnection;
       
   135 
       
   136     // Keeps track if current object caused the application to start
       
   137     bool mPendingConnection;
       
   138 
       
   139     // In case application starts while listening to push.
       
   140     bool mListening;
       
   141     // Keeps track of current object is created by push.
       
   142     bool mCreatedByPush;
       
   143 
       
   144     // If set, then it will clear the Service class bits at the time of close()
       
   145     bool mClearServiceClassBitsFlag;
       
   146 };
       
   147 
       
   148 } // namespace java
       
   149 } // namespace bluetooth
       
   150 
       
   151 #endif // BTL2CAPPUSHSERVERCONNECTION_H
       
   152