1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
17 */ |
17 */ |
18 |
18 |
19 |
19 |
20 #include <usif/scr/scr.h> |
20 #include <usif/scr/scr.h> |
21 #include <usif/sts/sts.h> |
21 #include <usif/sts/sts.h> |
|
22 #include "sifutils.h" |
|
23 #include "scr_internal.h" |
22 |
24 |
23 namespace Usif |
25 EXPORT_C void Usif::UninstallL(TComponentId aComponentId) |
24 { |
26 { |
25 EXPORT_C void UninstallL(TComponentId aComponentId) |
27 // Connect to the SCR and start a transaction |
|
28 RSoftwareComponentRegistry scr; |
|
29 User::LeaveIfError(scr.Connect()); |
|
30 CleanupClosePushL(scr); |
|
31 scr.CreateTransactionL(); |
|
32 // Connect to the STS and start a transaction |
|
33 RStsSession sts; |
|
34 sts.CreateTransactionL(); |
|
35 CleanupClosePushL(sts); |
|
36 // Get a list of files to be deleted |
|
37 RSoftwareComponentRegistryFilesList fileList; |
|
38 fileList.OpenListL(scr, aComponentId); |
|
39 CleanupClosePushL(fileList); |
|
40 // Unregister and delete the files from iFileList |
|
41 HBufC* file = NULL; |
|
42 while ((file = fileList.NextFileL()) != NULL) |
26 { |
43 { |
27 // Connect to the SCR and start a transaction |
44 CleanupStack::PushL(file); |
28 RSoftwareComponentRegistry scr; |
45 sts.RemoveL(*file); |
29 User::LeaveIfError(scr.Connect()); |
46 CleanupStack::PopAndDestroy(file); |
30 CleanupClosePushL(scr); |
47 } |
31 scr.CreateTransactionL(); |
48 CleanupStack::PopAndDestroy(&fileList); |
|
49 |
|
50 // Delete the component from the SCR |
|
51 scr.DeleteComponentL(aComponentId); |
32 |
52 |
33 // Connect to the STS and start a transaction |
53 // Commit the STS & SCR transactions |
34 RStsSession sts; |
54 sts.CommitL(); |
35 sts.CreateTransactionL(); |
55 scr.CommitTransactionL(); |
36 CleanupClosePushL(sts); |
56 CleanupStack::PopAndDestroy(2, &scr); |
|
57 } |
|
58 |
|
59 EXPORT_C TUid Usif::GenerateNewAppUidL() |
|
60 { |
|
61 // Connect to SCR using the internal client. |
|
62 RScrInternalClient scr; |
|
63 User::LeaveIfError(scr.Connect()); |
|
64 CleanupClosePushL(scr); |
|
65 |
|
66 //Request for an unused UID. |
|
67 TUid generatedUid = scr.GenerateNewAppUidL(); |
|
68 |
|
69 CleanupStack::PopAndDestroy(&scr); |
|
70 return generatedUid; |
|
71 } |
37 |
72 |
38 // Get a list of files to be deleted |
|
39 RSoftwareComponentRegistryFilesList fileList; |
|
40 fileList.OpenListL(scr, aComponentId); |
|
41 CleanupClosePushL(fileList); |
|
42 |
73 |
43 // Unregister and delete the files from iFileList |
|
44 HBufC* file = NULL; |
|
45 while ((file = fileList.NextFileL()) != NULL) |
|
46 { |
|
47 CleanupStack::PushL(file); |
|
48 sts.RemoveL(*file); |
|
49 CleanupStack::PopAndDestroy(file); |
|
50 } |
|
51 CleanupStack::PopAndDestroy(&fileList); |
|
52 |
|
53 // Delete the component from the SCR |
|
54 scr.DeleteComponentL(aComponentId); |
|
55 |
|
56 // Commit the STS & SCR transactions |
|
57 sts.CommitL(); |
|
58 scr.CommitTransactionL(); |
|
59 |
|
60 CleanupStack::PopAndDestroy(2, &scr); |
|
61 } |
|
62 } // namespace Usif |
|