sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <e32base.h>
|
sl@0
|
17 |
#include <e32def.h>
|
sl@0
|
18 |
#include <e32property.h>
|
sl@0
|
19 |
#include <e32debug.h>
|
sl@0
|
20 |
#include "TPropertyManager.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
_LIT(KSeparator, "|"); // Char used to separate arguments
|
sl@0
|
23 |
_LIT(KPropertyManagerSrvName,"TPropertyManagerSrv");
|
sl@0
|
24 |
_LIT(KPropertyManagerPanic,"TPropertyManager::SetProperty");
|
sl@0
|
25 |
|
sl@0
|
26 |
TInt PropertyManager::LaunchHelperProcess(TOperation aOperation,TDesC& aArgs)
|
sl@0
|
27 |
{
|
sl@0
|
28 |
TBuf<64> args;
|
sl@0
|
29 |
args.AppendNum(aOperation);
|
sl@0
|
30 |
args.Append(KSeparator);
|
sl@0
|
31 |
args.Append(aArgs);
|
sl@0
|
32 |
|
sl@0
|
33 |
// Property Manager Srv uid
|
sl@0
|
34 |
const TUid KSystemAgentExeUid = {0x10204FC5};
|
sl@0
|
35 |
const TUidType serverUid(KNullUid, KNullUid, KSystemAgentExeUid);
|
sl@0
|
36 |
RProcess server;
|
sl@0
|
37 |
TInt err = server.Create(KPropertyManagerSrvName, args, serverUid);
|
sl@0
|
38 |
if(err != KErrNone)
|
sl@0
|
39 |
{
|
sl@0
|
40 |
RDebug::Print(_L("Error Launching Property Manager..."));
|
sl@0
|
41 |
return err;
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
RDebug::Print(_L("Property Manager Launched..."));
|
sl@0
|
45 |
TRequestStatus stat;
|
sl@0
|
46 |
server.Rendezvous(stat);
|
sl@0
|
47 |
if(stat != KRequestPending)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
server.Kill(0); // abort startup
|
sl@0
|
50 |
}
|
sl@0
|
51 |
else
|
sl@0
|
52 |
{
|
sl@0
|
53 |
server.Resume(); // logon OK - start the server
|
sl@0
|
54 |
}
|
sl@0
|
55 |
User::WaitForRequest(stat); // wait for start or death
|
sl@0
|
56 |
// we can't use the 'exit reason' if the server panicked as this
|
sl@0
|
57 |
// is the panic 'reason' and may be '0' which cannot be distinguished
|
sl@0
|
58 |
// from KErrNone
|
sl@0
|
59 |
err = server.ExitType() == EExitPanic ? KErrGeneral : stat.Int();
|
sl@0
|
60 |
server.Close();
|
sl@0
|
61 |
|
sl@0
|
62 |
RDebug::Print(_L("Property Manager Terminated..."));
|
sl@0
|
63 |
return err;
|
sl@0
|
64 |
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
EXPORT_C TInt PropertyManager::DefineProperty(TUid aCategory, TUint aKey, TInt aAttr,TInt aPreallocated)
|
sl@0
|
68 |
{
|
sl@0
|
69 |
TBuf<64> args;
|
sl@0
|
70 |
args.AppendNum(aCategory.iUid);
|
sl@0
|
71 |
args.Append(KSeparator);
|
sl@0
|
72 |
args.AppendNum(aKey);
|
sl@0
|
73 |
args.Append(KSeparator);
|
sl@0
|
74 |
args.AppendNum(aAttr);
|
sl@0
|
75 |
args.Append(KSeparator);
|
sl@0
|
76 |
args.AppendNum(aPreallocated);
|
sl@0
|
77 |
|
sl@0
|
78 |
return LaunchHelperProcess(EDefineProperty,args);
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
EXPORT_C TInt PropertyManager::DeleteProperty(TUid aCategory, TUint aKey)
|
sl@0
|
82 |
{
|
sl@0
|
83 |
TBuf<64> args;
|
sl@0
|
84 |
args.AppendNum(aCategory.iUid);
|
sl@0
|
85 |
args.Append(KSeparator);
|
sl@0
|
86 |
args.AppendNum(aKey);
|
sl@0
|
87 |
|
sl@0
|
88 |
return LaunchHelperProcess(EDeleteProperty,args);
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
EXPORT_C TInt PropertyManager::SetProperty(TUid aCategory, TUint aKey, TInt aValue)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
TBuf<64> args;
|
sl@0
|
94 |
args.AppendNum(aCategory.iUid);
|
sl@0
|
95 |
args.Append(KSeparator);
|
sl@0
|
96 |
args.AppendNum(aKey);
|
sl@0
|
97 |
args.Append(KSeparator);
|
sl@0
|
98 |
args.AppendNum(aValue);
|
sl@0
|
99 |
|
sl@0
|
100 |
return LaunchHelperProcess(ESetPropertyInt,args);
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
EXPORT_C TInt PropertyManager::SetProperty(TUid aCategory, TUint aKey, const TDesC8 &aValue)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
TBuf<64> args;
|
sl@0
|
106 |
args.AppendNum(aCategory.iUid);
|
sl@0
|
107 |
args.Append(KSeparator);
|
sl@0
|
108 |
args.AppendNum(aKey);
|
sl@0
|
109 |
args.Append(KSeparator);
|
sl@0
|
110 |
|
sl@0
|
111 |
//Need to check maximum length of this field....
|
sl@0
|
112 |
if((args.Size() + aValue.Size()) > args.MaxSize())
|
sl@0
|
113 |
{
|
sl@0
|
114 |
User::Panic(KPropertyManagerPanic,0);
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
//Convert the 8Bit descriptor into a 16 bit version
|
sl@0
|
118 |
TBuf<128> value;
|
sl@0
|
119 |
value.Copy(aValue);
|
sl@0
|
120 |
args.Append(value);
|
sl@0
|
121 |
|
sl@0
|
122 |
return LaunchHelperProcess(ESetPropertyDes8,args);
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
EXPORT_C TInt PropertyManager::SetProperty(TUid aCategory, TUint aKey, const TDesC16 &aValue)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
TBuf<64> args;
|
sl@0
|
128 |
args.AppendNum(aCategory.iUid);
|
sl@0
|
129 |
args.Append(KSeparator);
|
sl@0
|
130 |
args.AppendNum(aKey);
|
sl@0
|
131 |
args.Append(KSeparator);
|
sl@0
|
132 |
|
sl@0
|
133 |
//Need to check maximum size of this field....
|
sl@0
|
134 |
if((args.Size() + aValue.Size()) < args.MaxSize())
|
sl@0
|
135 |
{
|
sl@0
|
136 |
User::Panic(KPropertyManagerPanic,0);
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
args.Append(aValue);
|
sl@0
|
140 |
|
sl@0
|
141 |
return LaunchHelperProcess(ESetPropertyDes16,args);
|
sl@0
|
142 |
}
|