javaextensions/bluetooth/bluetoothplugins/btspppushplugin/inc/btrfcommpushserverconnection.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 BTRFCOMMPUSHSERVERCONNECTION_H
       
    20 #define BTRFCOMMPUSHSERVERCONNECTION_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 "btrfcommserverconnection.h"
       
    37 
       
    38 #include "bturlparams.h"
       
    39 
       
    40 #include "serverconnectionfactorybase.h"
       
    41 namespace java
       
    42 {
       
    43 namespace bluetooth
       
    44 {
       
    45 
       
    46 /**
       
    47  * RFCOMPushServerConnection implements ServerConnection. Used by Push framework.
       
    48  *
       
    49  */
       
    50 class RFCOMMPushServerConnection: public java::push::ServerConnection,
       
    51         public BluetoothPushEventListener
       
    52 {
       
    53 
       
    54 public:
       
    55     OS_IMPORT RFCOMMPushServerConnection(const std::wstring aUri,
       
    56                                          const std::wstring aFilter,
       
    57                                          java::push::ServerConnectionFactoryBase* aFactory);
       
    58 
       
    59     OS_IMPORT virtual ~RFCOMMPushServerConnection();
       
    60 
       
    61     /**
       
    62      * This operation opens physical protocol connection.
       
    63      * @param aListener This operation does not take ownership of this pointer.
       
    64      * @throws PushException with COMMON_SRV_CONN_PLUGIN_ERROR error code if
       
    65      *         creation of the connection fails.
       
    66      */
       
    67     OS_IMPORT virtual void open(java::push::ConnectionListener* aListener);
       
    68 
       
    69     /**
       
    70      * This operation closes physical protocol connection.
       
    71      * This operation does not throw an exception.
       
    72      */
       
    73     OS_IMPORT virtual void close();
       
    74 
       
    75     /**
       
    76      * @return connection URI.
       
    77      */
       
    78     OS_IMPORT virtual std::wstring getUri() const;
       
    79 
       
    80     /**
       
    81      * @return filter URI of the push connection. Empty string is returned in the normal
       
    82      *         ServerConnection case.
       
    83      */
       
    84     OS_IMPORT virtual std::wstring getFilter() const;
       
    85 
       
    86     /**
       
    87      * Sets 'filter' argument for the connection. This method is needed in the situation where
       
    88      * 'normal' ServerConnection has been created before dynamic push registration.
       
    89      */
       
    90     OS_IMPORT virtual void setFilter(const std::wstring& aFilter);
       
    91 
       
    92     virtual void handleConnectionRequest(
       
    93         BluetoothClientConnection* aClientConnection, TInt err);
       
    94 
       
    95     OS_IMPORT bool isActive();
       
    96 
       
    97     OS_IMPORT bool isGOEPConnection();
       
    98 
       
    99     OS_IMPORT bool isConnectionAccepted();
       
   100 
       
   101     OS_IMPORT bool isListening();
       
   102 
       
   103     OS_IMPORT bool isCreatedByPush();
       
   104 
       
   105     OS_IMPORT void setCreatedByPush();
       
   106 
       
   107     OS_IMPORT RFCOMMServerConnection* getServerObject();
       
   108 
       
   109     OS_IMPORT void deleteServer();
       
   110 
       
   111     OS_IMPORT BluetoothClientConnection* getConnectedClient();
       
   112 
       
   113     OS_IMPORT void setAcceptMonitor(java::util::Monitor* aMonitor);
       
   114 
       
   115     OS_IMPORT void unsetAcceptMonitor();
       
   116 
       
   117     OS_IMPORT void unsetClearServiceClassBitsFlag();
       
   118 
       
   119 private:
       
   120     java::util::Monitor* mAcceptMonitor;
       
   121 
       
   122     java::push::ConnectionListener* mConnectionListener;
       
   123 
       
   124     std::wstring mConnectionUri;
       
   125 
       
   126     std::wstring mConnectionFilter;
       
   127 
       
   128     // Holds the URL/Filter parameters
       
   129     BtUrlParams* mBtUrlParams;
       
   130 
       
   131     // Bluetooth Function Server. To be used for async calls.
       
   132     BluetoothFunctionServer* mFunctionServer;
       
   133 
       
   134     // Reference to Server object.
       
   135     RFCOMMServerConnection* mRFCOMMServer;
       
   136 
       
   137     // Reference to Server connection factory.
       
   138     java::push::ServerConnectionFactoryBase* mConnectionFactory;
       
   139 
       
   140     // Holds reference to Client connection on successful push invocation.
       
   141     BluetoothClientConnection* mClientConnection;
       
   142 
       
   143     // Indicates whether it is a RFCOMM/OBEX connection
       
   144     bool mIsGOEP;
       
   145 
       
   146     // Keeps track if current object caused the application to start
       
   147     bool mPendingConnection;
       
   148 
       
   149     // In case application starts while listening to push.
       
   150     bool mListening;
       
   151 
       
   152     // Keeps track of current object is created by push.
       
   153     bool mCreatedByPush;
       
   154 
       
   155     // If set, then it will clear the Service class bits at the time of close()
       
   156     bool mClearServiceClassBitsFlag;
       
   157 };
       
   158 
       
   159 } // namespace java
       
   160 } // namespace bluetooth
       
   161 
       
   162 #endif // BTRFCOMMPUSHSERVERCONNECTION_H
       
   163