1 /* |
|
2 * Copyright (c) 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: Server side DS and DM sync services |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <SyncServiceSession.h> |
|
22 #include <SyncServiceParams.h> |
|
23 #include "SyncServiceDebug.h" |
|
24 |
|
25 #include <eikenv.h> |
|
26 #include <eikappui.h> |
|
27 #include <s32mem.h> |
|
28 |
|
29 const TInt KMemoryStoreBuffSize = 127; |
|
30 |
|
31 // ---------------------------------------------------------------------------- |
|
32 // CSyncServiceSession::CSyncServiceSesson |
|
33 // ---------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C CSyncServiceSession::CSyncServiceSession( ) |
|
36 : iDoc( CEikonEnv::Static()->EikAppUi()->Document() ) |
|
37 { |
|
38 FLOG( _L( "[CSyncServiceSession] CSyncServiceSession" ) ); |
|
39 } |
|
40 |
|
41 // ---------------------------------------------------------------------------- |
|
42 // CSyncServiceSession::~CSyncServiceSesson |
|
43 // ---------------------------------------------------------------------------- |
|
44 // |
|
45 CSyncServiceSession::~CSyncServiceSession() |
|
46 { |
|
47 FLOG( _L( "[CSyncServiceSession] ~CSyncServiceSession" ) ); |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CSyncServiceSession::CreateL |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 void CSyncServiceSession::CreateL() |
|
55 { |
|
56 FLOG( _L( "[CSyncServiceSession] CreateL" ) ); |
|
57 |
|
58 CAknAppServiceBase::CreateL(); |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // CSyncServiceSession::ServiceL |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 void CSyncServiceSession::ServiceL( const RMessage2& aMessage ) |
|
66 { |
|
67 FLOG( _L( "[CSyncServiceSession] ServiceL" ) ); |
|
68 |
|
69 switch( aMessage.Function() ) |
|
70 { |
|
71 case ESyncServiceCommand: |
|
72 OpenEmbeddedL( aMessage ); |
|
73 break; |
|
74 default: |
|
75 CAknAppServiceBase::ServiceL( aMessage ); |
|
76 break; |
|
77 } |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // CSyncServiceSession::ServiceError |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 void CSyncServiceSession::ServiceError( const RMessage2& aMessage, TInt aError ) |
|
85 { |
|
86 FLOG( _L( "[CSyncServiceSession] ServiceError" ) ); |
|
87 |
|
88 CAknAppServiceBase::ServiceError( aMessage, aError ); |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------------------------------- |
|
92 // CSyncServiceSession::OpenEmbeddedL |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 void CSyncServiceSession::OpenEmbeddedL( const RMessage2& aMessage ) |
|
96 { |
|
97 FLOG( _L( "[CSyncServiceSession] OpenEmbeddedL" ) ); |
|
98 |
|
99 TSyncParameters params; |
|
100 params.iCommand = aMessage.Int0(); |
|
101 params.iJobId = aMessage.Int1(); |
|
102 params.iProfileId = aMessage.Int2(); |
|
103 params.iSilent = aMessage.Int3(); |
|
104 CBufStore* store = CBufStore::NewLC( KMemoryStoreBuffSize ); |
|
105 RStoreWriteStream outStream; |
|
106 TStreamId id = outStream.CreateLC( *store ); |
|
107 params.ExternalizeL( outStream ); |
|
108 store->CommitL(); |
|
109 CleanupStack::PopAndDestroy();//outStream |
|
110 |
|
111 CStreamDictionary* dic = CStreamDictionary::NewLC(); |
|
112 dic->AssignL( KUidSyncParameterValue, id ); |
|
113 outStream.CreateLC( *store ); |
|
114 dic->ExternalizeL( outStream ); |
|
115 store->CommitL(); |
|
116 CleanupStack::PopAndDestroy();// outstream |
|
117 |
|
118 // Restore the document from this store |
|
119 RStoreReadStream readStream; |
|
120 readStream.OpenLC( *store, id ); |
|
121 iDoc->RestoreL( *store, *dic ); |
|
122 |
|
123 CleanupStack::PopAndDestroy(3);// dic, store, readStream |
|
124 aMessage.Complete( KErrNone ); |
|
125 } |
|
126 |
|
127 // End of File |
|