1 /* |
|
2 * Copyright (c) 2010 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: Security dialog notifier server, client-side API. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "securitydialognotifiersrv.h" // RSecurityDialogNotifierSrv |
|
19 #include "../../securitydialognotifiersrv/inc/securitydialognotifierservername.h" |
|
20 #include "securitydialogstrace.h" // TRACE macro |
|
21 |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // RSecurityDialogNotifierSrv::RSecurityDialogNotifierSrv() |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 RSecurityDialogNotifierSrv::RSecurityDialogNotifierSrv() |
|
30 { |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // RSecurityDialogNotifierSrv::~RSecurityDialogNotifierSrv() |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 RSecurityDialogNotifierSrv::~RSecurityDialogNotifierSrv() |
|
38 { |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // RSecurityDialogNotifierSrv::Connect() |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 TInt RSecurityDialogNotifierSrv::Connect() |
|
46 { |
|
47 TRACE( "RSecurityDialogNotifierSrv::Connect" ); |
|
48 const TInt KMaxCreateSessionAttepmts = 2; |
|
49 TInt retry = KMaxCreateSessionAttepmts; |
|
50 FOREVER |
|
51 { |
|
52 TInt err = CreateSession( KSecurityDialogNotifierServerName, Version() ); |
|
53 TRACE( "RSecurityDialogNotifierSrv::Connect, create session err=%d", err ); |
|
54 if( err != KErrNotFound && err != KErrServerTerminated ) |
|
55 { |
|
56 return err; |
|
57 } |
|
58 |
|
59 if( --retry == 0 ) |
|
60 { |
|
61 return err; |
|
62 } |
|
63 |
|
64 err = StartServer(); |
|
65 if( err != KErrNone && err != KErrAlreadyExists ) |
|
66 { |
|
67 return err; |
|
68 } |
|
69 } |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // RSecurityDialogNotifierSrv::Version() |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 TVersion RSecurityDialogNotifierSrv::Version() const |
|
77 { |
|
78 return TVersion( KSecurityDialogNotifierServerMajorVersionNumber, |
|
79 KSecurityDialogNotifierServerMinorVersionNumber, |
|
80 KSecurityDialogNotifierServerBuildVersionNumber ); |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // RSecurityDialogNotifierSrv::SecurityDialogOperationL() |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void RSecurityDialogNotifierSrv::SecurityDialogOperation( |
|
88 TSecurityDialogOperation aOperation, |
|
89 const TDesC8& aInputBuffer, TDes8& aOutputBuffer, |
|
90 TRequestStatus& aStatus ) |
|
91 { |
|
92 TRACE( "RSecurityDialogNotifierSrv::SecurityDialogOperation" ); |
|
93 iArgs = TIpcArgs( &aInputBuffer, &aOutputBuffer ); |
|
94 SendReceive( aOperation, iArgs, aStatus ); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // RSecurityDialogNotifierSrv::CancelOperation() |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 void RSecurityDialogNotifierSrv::CancelOperation() |
|
102 { |
|
103 TRACE( "RSecurityDialogNotifierSrv::CancelOperation" ); |
|
104 SendReceive( KSecurityDialogCancelOperation ); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // RSecurityDialogNotifierSrv::StartServer() |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 TInt RSecurityDialogNotifierSrv::StartServer() |
|
112 { |
|
113 TRACE( "RSecurityDialogNotifierSrv::StartServer, begin" ); |
|
114 RProcess server; |
|
115 TInt err = server.Create( KSecurityDialogNotifierServerName, KNullDesC ); |
|
116 if( err ) |
|
117 { |
|
118 TRACE( "RSecurityDialogNotifierSrv::StartServer, create failed, err=%d", err ); |
|
119 return err; |
|
120 } |
|
121 |
|
122 TRequestStatus status; |
|
123 server.Rendezvous( status ); |
|
124 if( status == KRequestPending ) |
|
125 { |
|
126 server.Resume(); |
|
127 } |
|
128 else |
|
129 { |
|
130 server.Kill( KErrNone ); |
|
131 } |
|
132 |
|
133 TRACE( "RSecurityDialogNotifierSrv::StartServer, waiting rendezvous" ); |
|
134 User::WaitForRequest( status ); |
|
135 if( server.ExitType() == EExitPanic ) |
|
136 { |
|
137 err = KErrGeneral; |
|
138 } |
|
139 else |
|
140 { |
|
141 err = status.Int(); |
|
142 } |
|
143 server.Close(); |
|
144 |
|
145 TRACE( "RSecurityDialogNotifierSrv::StartServer, end err=%d", err ); |
|
146 return err; |
|
147 } |
|
148 |
|