javaextensions/bluetooth/bluetoothcommons/inc.s60/bturlparams.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 BTURLPARAMS_H
       
    20 #define BTURLPARAMS_H
       
    21 
       
    22 #include <list>
       
    23 #include <string>
       
    24 
       
    25 namespace java
       
    26 {
       
    27 namespace bluetooth
       
    28 {
       
    29 
       
    30 // For URLs
       
    31 #define SEMICOLON                   L";"
       
    32 #define EQUAL                       L"="
       
    33 
       
    34 #define PROTOCOL_SEPERATOR          L"://"
       
    35 #define LOCALHOST                   L"localhost:"
       
    36 
       
    37 #define URL_PARAM_AUTHENTICATE      L";authenticate="
       
    38 #define URL_PARAM_AUTHORIZE         L";authorize="
       
    39 #define URL_PARAM_ENCRYPT           L";encrypt="
       
    40 #define URL_PARAM_MASTER            L";master="
       
    41 #define URL_PARAM_NAME              L";name="
       
    42 #define URL_PARAM_RECEIVE_MTU       L";receivemtu="
       
    43 #define URL_PARAM_TRANSMIT_MTU      L";transmitmtu="
       
    44 
       
    45 // For Filters
       
    46 #define FILTER_PARAM_BLACKLIST      L";blacklist="
       
    47 #define FILTER_PARAM_AUTHENTICATED  L";authenticated"
       
    48 #define FILTER_PARAM_AUTHORIZED     L";authorized"
       
    49 
       
    50 class BtUrlParams
       
    51 {
       
    52 public:
       
    53     OS_IMPORT BtUrlParams(std::wstring aUrl, std::wstring aFilter);
       
    54     OS_IMPORT ~BtUrlParams();
       
    55 
       
    56     // Getter functions
       
    57     OS_IMPORT std::wstring getProtocol();
       
    58     OS_IMPORT std::wstring getServiceUuid();
       
    59     OS_IMPORT std::wstring getParamName();
       
    60     OS_IMPORT bool getParamMaster();
       
    61     OS_IMPORT bool getParamAuthorize();
       
    62     OS_IMPORT bool getParamAuthenticate();
       
    63     OS_IMPORT bool getParamEncrypt();
       
    64     OS_IMPORT int getParamReceiveMtu();
       
    65     OS_IMPORT int getParamTransmitMtu();
       
    66 
       
    67     OS_IMPORT
       
    68     bool isAllowedSender(HBufC& aDevAddr, bool &aAuthorized,
       
    69                          bool &aAuthenticated);
       
    70     OS_IMPORT bool isBlockedSender(HBufC& aDevAddr);
       
    71 
       
    72 private:
       
    73     // Methods
       
    74     BtUrlParams();
       
    75     void extractUrlParams(std::wstring aUrl);
       
    76     void extractFilterParams(std::wstring aFilter);
       
    77     void setUrlParamsValue(std::wstring aParam, std::wstring aVal);
       
    78     void fillBlackList(std::wstring aBlackList);
       
    79     std::wstring &ToLower(std::wstring &aStr);
       
    80     std::wstring BtUrlParams::validLongUuid(std::wstring &aStr);
       
    81 
       
    82     bool matchWS(HBufC& aDevAddr, std::wstring aPattern);
       
    83     bool matchHB(HBufC& aDevAddr, HBufC &aPattern);
       
    84 
       
    85 private:
       
    86     // Extracted data
       
    87     class AllowedSender
       
    88     {
       
    89     public:
       
    90         std::wstring mPattern;
       
    91         bool mAuthorized;
       
    92         bool mAuthenticated;
       
    93     } mAllowedSenders;
       
    94 
       
    95     bool mMaster;
       
    96     bool mAuthorize;
       
    97     bool mAuthenticate;
       
    98     bool mEncrypt;
       
    99     int mTransmitMtu;
       
   100     int mReceiveMtu;
       
   101     std::wstring mName;
       
   102     std::wstring mServiceUuid;
       
   103     std::wstring mProtocol;
       
   104     std::list<HBufC*> mBlockedSenders;
       
   105     std::locale mLocale;
       
   106 
       
   107     // internal data
       
   108     std::wstring mUrl;
       
   109     std::wstring mFilter;
       
   110 };
       
   111 
       
   112 } //end namespace bluetooth
       
   113 } //end namespace java
       
   114 
       
   115 #endif // BTURLPARAMS_H