webservices/wscore/inc/sencoreservicemanager.h
changeset 0 62f9d29f7211
child 14 ab1e518f96da
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:    Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 #ifndef SEN_CORE_SERVICE_MANAGER_H
       
    29 #define SEN_CORE_SERVICE_MANAGER_H
       
    30 
       
    31 //  INCLUDES
       
    32 #include <e32base.h>
       
    33 #include <badesca.h>
       
    34 #include <f32file.h>
       
    35 #include <imcvcodc.h> // for base64 codec
       
    36 #include <flogger.h>
       
    37 #include <etelmm.h>
       
    38 
       
    39 #include <SenXmlReader.h>
       
    40 
       
    41 #include "senservicemanagerdefines.h"
       
    42 #include "msencoreservicemanager.h"
       
    43 #include "senxmldao.h"
       
    44 #include "msentransport.h"
       
    45 
       
    46 // CONSTANTS
       
    47 #ifdef EKA2 
       
    48 
       
    49 // Server's policy here
       
    50 
       
    51 // Total number of ranges
       
    52 const TUint KCoreServiceManagerRangeCount = 11;	//CodeScannerWarnings
       
    53 
       
    54 // Definition of the ranges of IPC numbers
       
    55 // NOTE: ranges MUST start from request number 0  (!)
       
    56 const TInt coreServiceManagerRanges[KCoreServiceManagerRangeCount] = 
       
    57         {
       
    58         0,  // ESenServInitialize,
       
    59         1,  // ESenServTransaction,
       
    60         2,  // ESenServInstallFramework,
       
    61         3,  // ESenServAssociateService,
       
    62             // ESenServDissociateService, 
       
    63             // ESenServRegisterIdentityProvider,
       
    64             // ESenServUnregisterIdentityProvider,
       
    65             // ESenServRegisterServiceDescription,
       
    66             // ESenServUnregisterServiceDescription,
       
    67         9,  // ESenServGetServiceDescriptionsByPattern, 
       
    68             // ESenServGetServiceDescriptionsByUri,
       
    69         11, // ESenServIsReady,
       
    70             // ESenServHasFacet,
       
    71             // ESenServServerMessagesOnOff,
       
    72         14, // ESenServGetLengthOfServiceDescriptionByUri,
       
    73             // ESenServGetLengthOfServiceDescriptionByPattern,
       
    74         16, // ESenServRequestServiceDescription,
       
    75             // ESenServReceiveServiceDescription,
       
    76         18, // ESenServSendMsgAndGetTxnId,
       
    77             // ESenServSendSoapMsgAndGetTxnId,
       
    78         20, // ESenServStartTransaction,
       
    79             // ESenServTransactionCompleted,
       
    80             // ESenServCancelSession,
       
    81             // ESenServSetTransportProperties,
       
    82             // ESenServTransportProperties
       
    83             // ESenServCreateHostletConnection, 
       
    84             // ESenServWaitForHostletRequest    
       
    85             // ESenServProvideHostletResponse   
       
    86             // ESenServMoveChunk
       
    87             // ESenServMoveFile
       
    88             // ESenServSendFileHandle
       
    89             // ESenServGetGredentials
       
    90             // ESenServAddCredential
       
    91             // ESenServRemoveCredential
       
    92             // ESenServCancelRequest
       
    93             // ESenServConnectionID
       
    94             // ESenServConnectionIdentityProvider
       
    95             // ESenObserveTransfer
       
    96             // ESenObserveAuthCallback
       
    97             // ESenTransferProgress
       
    98         	// ESenServSearchIdentityProvider
       
    99             // ESenServTrafficDetails
       
   100 	    // ESenObserveCoBranding	
       
   101         	// ESenServGetIdentityProviders
       
   102 #ifdef __ENABLE_ALR__
       
   103 			// ESenServRegisterMobiltyObserver
       
   104 			//ESenServMigrateToPreffredCarrier
       
   105 			//ESenServNewCarrierAccepted
       
   106         47
       
   107 #else
       
   108 		44
       
   109 #endif
       
   110         }; 
       
   111 
       
   112 // Policy to implement for each of the above ranges        
       
   113 const TUint8 coreServiceManagerElementsIndex[KCoreServiceManagerRangeCount] = 
       
   114         {
       
   115         2,                           //applies to 1st range  <=>  0
       
   116         CPolicyServer::EAlwaysPass,  //applies to 2nd range  <=>  1
       
   117         1,                           //applies to 3rd range  <=>  2
       
   118         3,                           //applies to 4th range  <=>  3 - 8
       
   119         0,                           //applies to 5th range  <=>  9 - 10
       
   120         CPolicyServer::EAlwaysPass,  //applies to 6th range  <=> 11 - 13
       
   121         0,                           //applies to 7th range  <=> 14 - 15
       
   122         CPolicyServer::EAlwaysPass,  //applies to 8th range  <=> 16 - 17
       
   123         2,                           //applies to 9th range  <=> 18 - 19
       
   124         CPolicyServer::EAlwaysPass,  //applies to 10th range <=> 20 - 35
       
   125         CPolicyServer::ENotSupported //applies to 11th range (out of range IPC; >35)
       
   126         };
       
   127 
       
   128 // Specific capability checks
       
   129 const CPolicyServer::TPolicyElement coreServiceManagerElements[] = 
       
   130         {
       
   131         //policy "0"; fail call if ReadUserData not present
       
   132         {_INIT_SECURITY_POLICY_C1(ECapabilityReadUserData), CPolicyServer::EFailClient},  
       
   133         //policy "1"; fail call if WriteUserData not present
       
   134         {_INIT_SECURITY_POLICY_C1(ECapabilityWriteUserData), CPolicyServer::EFailClient}, 
       
   135         //policy "2"; fail call if NetworkServices not present
       
   136         {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkServices), CPolicyServer::EFailClient}, 
       
   137         //policy "3"; fail call if ReadUserData, WriteUserData not present
       
   138         {_INIT_SECURITY_POLICY_C2(ECapabilityReadUserData, ECapabilityWriteUserData), CPolicyServer::EFailClient}
       
   139         };
       
   140 
       
   141 // Package all the above together into a policy
       
   142 const CPolicyServer::TPolicy coreServiceManagerPolicy =
       
   143         {
       
   144         CPolicyServer::EAlwaysPass,         // specifies all connect attempts should pass 
       
   145         KCoreServiceManagerRangeCount,       // number of ranges                                   
       
   146         coreServiceManagerRanges,           // ranges array
       
   147         coreServiceManagerElementsIndex,    // elements<->ranges index
       
   148         coreServiceManagerElements,         // array of elements
       
   149         };
       
   150 
       
   151 #endif //EKA2
       
   152 
       
   153 // FORWARD DECLARATIONS
       
   154 class CSenGuidGen;
       
   155 class CSenBaseIdentityManager;
       
   156 class CSenCredentialManager;
       
   157 class CSenServerContext;
       
   158 class CSenCoreShutdownTimer;
       
   159 
       
   160 // CLASS DECLARATION
       
   161 
       
   162 #ifdef EKA2  
       
   163 class CSenCoreServiceManager : public CPolicyServer,
       
   164                                public MSenCoreServiceManager
       
   165 #else
       
   166 class CSenCoreServiceManager : public CServer2,
       
   167                                public MSenCoreServiceManager
       
   168 #endif
       
   169     {
       
   170     public: 
       
   171         
       
   172         // Constructors
       
   173         static CSenCoreServiceManager* NewL();
       
   174         static CSenCoreServiceManager* NewLC();
       
   175 
       
   176         // C++ destructor
       
   177         virtual ~CSenCoreServiceManager();
       
   178 
       
   179 
       
   180         // From MSenIdentityManager:
       
   181 
       
   182         virtual MSenIdentity& IdentityL();
       
   183         virtual TInt UserNameL(HBufC8*& aUserName);
       
   184         virtual CSenIdentityProvider* IdentityProviderL();
       
   185         virtual CSenIdentityProvider* IdentityProviderL(const TDesC8& aURI);
       
   186         virtual CSenIdentityProvider* IdentityProviderL(const CDesC8Array& aIdpList,
       
   187                                                         TBool aStrict);
       
   188 
       
   189         virtual CSenIdentityProvider* IdentityProviderL(MSenServiceDescription& aSD);
       
   190 
       
   191         virtual CSenIdentityProvider* IdentityProviderL(MSenServiceDescription& aSD,
       
   192                                                         const CDesC8Array& aIdpList,
       
   193                                                         TBool aStrict);
       
   194         virtual const RPointerArray<CSenIdentityProvider>& IdentityProvidersL();
       
   195 
       
   196         virtual TInt RegisterIdentityProviderL(CSenIdentityProvider* apIdp);
       
   197         virtual TInt UnregisterIdentityProviderL(CSenIdentityProvider& aIdp);
       
   198         virtual TBool AssociateServiceL(const TDesC8& aServiceID, const TDesC8& aProviderID);
       
   199         virtual TBool DissociateServiceL(const TDesC8& aServiceID, const TDesC8& aProviderID);
       
   200         virtual TInt IdentitiesL(CDesC8Array& aIdentitiesList);
       
   201         virtual TInt AuthenticationForL(CSenIdentityProvider& aAccount, TPckgBuf<TSenAuthentication>& aResponse);
       
   202         virtual TPtrC8 SenSecurityMechanismNames8L();
       
   203         virtual void SetShowPasswordDialog(const TBool aState);
       
   204         virtual CSenSecurityMechanism* MechanismNamedL(const TDesC8& aName);
       
   205 
       
   206         // From MSenServiceManager
       
   207         virtual TInt InitServiceConnectionL(MSenRemoteServiceConsumer& aServiceConsumer,
       
   208                                             CSenWSDescription& aPattern,
       
   209                                             HBufC8*& aErrorMsg);
       
   210 
       
   211         virtual TInt ServiceDescriptionsL(RWSDescriptionArray& aMatches,
       
   212                                           const TDesC8& aContract);
       
   213 
       
   214         virtual TInt ServiceDescriptionsL(RWSDescriptionArray& aMatches,
       
   215                                           MSenServiceDescription& aPattern);
       
   216 
       
   217         virtual TInt RegisterServiceDescriptionL(CSenWSDescription* apSD);
       
   218         virtual TInt UnregisterServiceDescriptionL(MSenServiceDescription& aSD);
       
   219         virtual CSenBaseFragment* InstallFrameworkL(const TDesC8& aFrameworkId);
       
   220         
       
   221         virtual TPtrC8 IMSI();
       
   222         
       
   223         virtual TPtrC8 IMEI();
       
   224 
       
   225         virtual CSenXmlReader* XMLReader();
       
   226         virtual HBufC8* RandomGuidL(); 
       
   227         virtual RFileLogger* Log() const;
       
   228         virtual void IncrementConnections();
       
   229         virtual void DecrementConnections();
       
   230 
       
   231 
       
   232         virtual TInt ContainsServiceDescriptionL(TBool& aContains,
       
   233                                                  CSenWSDescription& aPattern);
       
   234 
       
   235         virtual TInt ContainsIdentityProviderL(TBool& aContains,
       
   236                                                CSenIdentityProvider& aIDP);
       
   237                                                
       
   238         virtual TInt FindMatchingIdentityProviderL(CSenIdentityProvider &aIdp,
       
   239                                                    CSenIdentityProvider*& apMatch);
       
   240                                                    
       
   241         virtual TInt UpdateIdentityProviderL(CSenIdentityProvider& aIdp);
       
   242 
       
   243         virtual TInt NextTransactionId();
       
   244 
       
   245         /**
       
   246         * Notifies *ALL* framework plug-ins about certain event
       
   247         * @return some system-wide error code, if an error occurred
       
   248         */
       
   249         virtual TInt NotifyFrameworksL(const TInt aEvent);
       
   250 
       
   251         /**
       
   252         * Notifies *ALL* framework plug-ins about certain event,
       
   253         * an additional object pointer may be passed
       
   254         * NULL is also accepted
       
   255         * @return some system-wide error code, if an error occurred
       
   256         */
       
   257         virtual TInt NotifyFrameworksL(const TInt aEvent, TAny* aArgument);
       
   258 
       
   259         /**
       
   260         * Notifies only those frameworks plug-ins, which match
       
   261         * with given framework ID (aFrameworkID)
       
   262         * If aFrameworkID == KNullDesC8 (zero-length),
       
   263         * then *all* known framework plug-ins are notified about the event.
       
   264         * @return some system-wide error code, if an error occurred
       
   265         */
       
   266         virtual TInt NotifyFrameworksL(const TDesC8& aFrameworkID, 
       
   267                                        const TInt aEvent);
       
   268 
       
   269         /**
       
   270         * Notifies only those frameworks plug-ins, which match
       
   271         * with given framework ID (aFrameworkID)
       
   272         * If aFrameworkID == KNullDesC8 (zero-length),
       
   273         * then *all* known framework plug-ins are notified about the event,
       
   274         * an additional object pointer may be passed
       
   275         * NULL is also accepted
       
   276         * @return some system-wide error code, if an error occurred
       
   277         */
       
   278         virtual TInt NotifyFrameworksL(const TDesC8& aFrameworkID,
       
   279                                        const TInt aEvent,
       
   280                                        TAny* aArgument);
       
   281 
       
   282 
       
   283         virtual TInt SizeOfServiceDescriptionsL(RWSDescriptionArray& aArray);
       
   284         
       
   285         virtual TInt SizeOfCredentialsL(RSenCredentialArray& aArray);
       
   286         virtual TInt SizeOfIdentityProvidersL(const RPointerArray<CSenIdentityProvider>& aArray);
       
   287 
       
   288         // From MSenCoreServiceManager
       
   289     
       
   290         /**
       
   291         * Takes the ownership of apServiceDescription
       
   292         * @return KErrNone on success
       
   293         *         KErrArgument, if aServiceDescription is NULL
       
   294         *         KErrSenNoContractNoEndPoint, if both endpoint and
       
   295         *            contract are of zero-lenght, making SD invalid
       
   296         *         KErrGeneral if duplicate (blocking), service description
       
   297         *         with equal primary keys could not be removed.
       
   298         */
       
   299         virtual TInt AddServiceDescriptionL(CSenWSDescription* apServiceDescription);
       
   300 
       
   301         virtual TInt RemoveServiceDescriptionL(CSenWSDescription& aServiceDescription);
       
   302 
       
   303         virtual TInt SaveL(const CSenServiceSession& aServiceSession);
       
   304         virtual TInt SaveL(const CSIF& aServiceInvocationFramework);
       
   305 
       
   306         virtual CDesC8Array& SupportedFrameworksL();
       
   307 
       
   308         virtual MSenProvider& LookupHostletForL(const TDesC8& aHostletEndpoint,
       
   309                                                 const TDesC& aReqThreadId,
       
   310                                                 const TDesC8& aReqConsumerId);
       
   311 
       
   312         virtual TInt ReleaseHostletL(const MSenProvider* aHostlet,
       
   313                                      const TDesC& aReqThreadId,
       
   314                                      const TDesC8& aReqConsumerId);
       
   315 
       
   316 
       
   317         // From MSenTransportFactory:
       
   318         virtual CSenTransportBase* CreateL(CSenWSDescription& aInitializer,
       
   319                                            CSenServiceSession* apSession);
       
   320         
       
   321         // from CServer
       
   322         
       
   323         CSession2* NewSessionL(const TVersion &aVersion,
       
   324                                const RMessage2& aMessage) const; 
       
   325 
       
   326         static TInt ThreadFunction(TAny* sStarted);
       
   327 
       
   328         
       
   329         virtual HBufC8* EncodeToBase64LC(const TDesC8& aSource);
       
   330         virtual HBufC8* DecodeFromBase64LC(const TDesC8& aSource);
       
   331 
       
   332         // New functions
       
   333         virtual RStringPool& StringPool();
       
   334 
       
   335 /*
       
   336         // New functions
       
   337         virtual TInt AddActiveHostletConnectionEndpointL(const TDesC8& aEndpoint);
       
   338         virtual TInt RemoveActiveHostletConnectionEndpoint(const TDesC8& aEndpoint);
       
   339 */
       
   340 
       
   341         // From MSenCredentialManager
       
   342         
       
   343         virtual TInt SaveCredentialDB();
       
   344         
       
   345 		virtual TInt CredentialsL(const CSenWSDescription& aPattern,
       
   346                                   RSenCredentialArray& aCredentials);
       
   347 
       
   348 		virtual TInt CredentialsL(const CSenWSDescription& aPattern,
       
   349                                   const CSenIdentityProvider& aIdP,
       
   350                                   RSenCredentialArray& aCredentials);
       
   351 
       
   352 		virtual TInt CredentialsL(const CSenWSDescription& aPattern,
       
   353                                   RSenCredentialPtrArray& aCredentials);
       
   354 
       
   355 		virtual TInt CredentialsL(const CSenWSDescription& aPattern,
       
   356                                   const CSenIdentityProvider& aIdP,
       
   357                                   RSenCredentialPtrArray& aCredentials);
       
   358 
       
   359 		virtual RSenCredentialPtr AddCredentialL(CSenInternalCredential* apCredential,
       
   360                                                  TInt& aErrorTo);
       
   361 
       
   362 		virtual RSenCredentialPtr AddCredentialL(CSenIdentityProvider* apIdP,
       
   363                                                  CSenInternalCredential* apCredential,
       
   364 	                                             TInt& aErrorTo);
       
   365 
       
   366 		virtual RSenCredentialPtr AddCredentialL(const TDesC8& aCredential,
       
   367                                                  TInt& aErrorTo);
       
   368 
       
   369 		virtual RSenCredentialPtr AddCredentialL(CSenIdentityProvider* apIdP,
       
   370                                                  const TDesC8& aCredential,
       
   371                                                  TInt& aErrorTo);
       
   372 
       
   373 		virtual TInt RemoveCredentialsL(const CSenWSDescription& aPattern);
       
   374 
       
   375 		virtual TInt RemoveCredentialsL(const CSenWSDescription& aPattern,
       
   376 										const CSenIdentityProvider& aIdP);
       
   377 										
       
   378         virtual TInt RemoveCredentialsL(const TDesC8& aProviderId);
       
   379 
       
   380         virtual TInt RemoveCredentialL(TInt aInternalCredentialId);	//codescannerwarnings
       
   381         
       
   382         virtual RSenCredentialPtr CredentialL(TInt aInternalCredentialId,
       
   383                                               TInt& aErrorTo);
       
   384 
       
   385         virtual RSenCredentialPtr UpdateCredentialL(TInt aInternalCredentialId,
       
   386                                                     CSenInternalCredential* apCredential,
       
   387                                                     TInt& aErrorTo);
       
   388         
       
   389         virtual RSenCredentialPtr UpdateCredentialL(TInt aInternalCredentialId,
       
   390                                                     const TDesC8& aCredential,
       
   391                                                     TInt& aErrorTo);
       
   392 
       
   393         virtual TInt NextConnectionID();
       
   394 
       
   395     protected:  
       
   396         
       
   397         // From CActive
       
   398         TInt RunError(TInt aError);
       
   399 
       
   400     private: 
       
   401         
       
   402         /**
       
   403         * C++ default constructor.
       
   404         */
       
   405         CSenCoreServiceManager(TInt aPriority);
       
   406         
       
   407         /**
       
   408         * By default Symbian 2nd phase constructor is private.
       
   409         */
       
   410         void ConstructL();
       
   411 
       
   412         // New functions
       
   413         
       
   414         MSIF* Framework(const TDesC8& aFrameworkID);
       
   415         TImCodecB64& Base64Codec();
       
   416 
       
   417 //        RPointerArray<HBufC8>& ActiveHostletEndpointsL();
       
   418 
       
   419     private: 
       
   420         
       
   421         // CS framework:
       
   422         static void PanicClient(const RMessage2& aMessage,
       
   423                                 TWsfServPanic aReason);
       
   424 
       
   425         static void PanicServer(TWsfServPanic aPanic);
       
   426         static void ThreadFunctionL();
       
   427         void UpdateTouchL(CSenServiceSession* aSession);
       
   428         
       
   429         void GetImsiImeiL();
       
   430 
       
   431 
       
   432     private: // Data
       
   433         CSenXMLDAO*              iDAO;                      // owned
       
   434         CSenBaseIdentityManager* iIdentityManager;          // owned
       
   435         RFileLogger              iLog;                      // owned
       
   436         TInt                     iConnectionCount;
       
   437         CSenGuidGen*             iGuidGenerator;            // owned
       
   438         CSenXmlReader*           iReader;                   // owned
       
   439         TImCodecB64 iBase64Codec; 
       
   440         RStringPool iStringPool;                            // owned
       
   441 //        RPointerArray<HBufC8>*   ipActiveHostletEndpoints;  // owned
       
   442 
       
   443         TInt iNextTransactionId;
       
   444 
       
   445         CSenCredentialManager*   iCredentialManager;        // owned
       
   446         
       
   447         CSenTransportBase* ipVtcpTransport; // not owned
       
   448 //        HBufC8*        ipVtcpEndpoint;  // owned
       
   449 
       
   450         TInt                     iConnectionID;
       
   451         
       
   452         CSenServerContext* ipServerContext; // owned
       
   453         CSenCoreShutdownTimer* iShutdownTimer;
       
   454         TBuf8<15> iIMSI;
       
   455         TBuf8<50> iIMEI;
       
   456     };
       
   457 
       
   458 #endif // SEN_CORE_SERVICE_MANAGER_H
       
   459 
       
   460 // End of File