os/security/authorisation/userpromptservice/examples/integration/tmsgserver/tmsgserver.h
Update contrib.
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
32 #include <ups/upsclient.h>
35 // Standard shutdown timer for transient servers
36 class CShutdown : public CTimer
38 enum {KMyShutdownDelay=0x200000}; // approx 2s
41 inline void ConstructL();
49 EPanicIllegalFunction,
53 Example system server that uses the User Prompt Service.
55 class CMsgServer : public CPolicyServer
58 static CMsgServer* NewLC();
59 CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
60 inline UserPromptService::RUpsSession& Ups();
63 TCustomResult CustomFailureActionL(const RMessage2& aMessage, TInt aAction, const TSecurityInfo& aMissing);
70 static const TInt KPolicyRanges = 3;
71 static const TInt KPolicyElements = 1;
72 static const TInt iRanges[KPolicyRanges];
73 static const TUint8 iElementsIndex[KPolicyRanges];
74 static const CPolicyServer::TPolicyElement iPolicyElements[KPolicyElements];
75 static const CPolicyServer::TPolicy iPolicy;
79 UserPromptService::RUpsSession iUps; /// UPS session class held by Server
83 Active object that asynchronously processes the sending of a message.
84 An extra state is added to support UPS authorisation.
85 In a more complicated server there may be several different message processor
88 class CMsgProcessor : public CActive
90 enum TState {EIdle, EAuthorising, ESending};
92 static CMsgProcessor* NewL(UserPromptService::RUpsSubsession& aAuth);
93 void ProcessL(const RMessage2& aMessage, TBool aPlatsecResult);
96 CMsgProcessor(UserPromptService::RUpsSubsession& aAuth);
100 TInt RunError(TInt aError);
102 void GetParamsL(const RMessage2& aMessage);
103 void AuthoriseL(const RMessage2& aMessage, TBool aPlatsecResult);
113 UserPromptService::RUpsSubsession& iAuth; /// Handle to UPS sub-session for client
114 TUpsDecision iDecision; /// Whether the request was authorised
115 TBool iPlatsecResult; /// Whether the platsec check passed
116 // In techview this corresponds to
117 // ups\policies\test\tupspolicies\resource\ups_01041000_01041001.rss
118 // and is recognised by the example UPS dialog creator and notifier.
119 static const TUint KServiceId = 0x01041001;
123 Session class for example message server that uses the User Prompt Service
125 class CMsgServerSession : public CSession2
130 void SetPlatsecResult(TBool aResult);
131 ~CMsgServerSession();
133 inline CMsgServer& Server();
134 void ServiceL(const RMessage2& aMessage);
135 CMsgProcessor* iProcessor;
137 /// Normally, a sub-session is created for each client or client connection
138 UserPromptService::RUpsSubsession iAuth;
139 /// Only initialise iAuth once
140 TBool iAuthInitialised;
141 /// RUpsSubsession::Authorise needs to know whether the platsec check passed
142 TBool iPlatsecResult;
144 #endif /* TMSGSERVER_H_*/