|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 // User include |
|
23 #include <t_utilsconfigfilemachinename.h> |
|
24 |
|
25 // Epoc include |
|
26 #include <f32file.h> |
|
27 |
|
28 |
|
29 //Literals used |
|
30 _LIT(KFileName,"c:\\smoketest\\MachineName.txt"); |
|
31 _LIT(KAtEmailAddress,"@msexchange2k.closedtest.intra"); |
|
32 |
|
33 |
|
34 /** |
|
35 NewL() |
|
36 Allocates and creates a new CT_MsgConnectPop3Server object |
|
37 |
|
38 @param aPtrEmailAdd |
|
39 @leave KErrNoMemory |
|
40 @return |
|
41 The newly created CT_MsgUtilsConfigFileMachineName object |
|
42 */ |
|
43 EXPORT_C CT_MsgUtilsConfigFileMachineName* CT_MsgUtilsConfigFileMachineName::NewL(const TDesC& aPtrEmailAdd) |
|
44 { |
|
45 CT_MsgUtilsConfigFileMachineName* self = new (ELeave) CT_MsgUtilsConfigFileMachineName(); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(aPtrEmailAdd); |
|
48 CleanupStack::Pop(self); |
|
49 return self; |
|
50 } |
|
51 |
|
52 |
|
53 /** |
|
54 NewLC() |
|
55 Allocates and creates a new CT_MsgUtilsConfigFileMachineName object, leaving the |
|
56 object on the cleanup stack. |
|
57 |
|
58 @param aPtrEmailAdd |
|
59 @leave KErrNoMemory |
|
60 @return |
|
61 The newly created CT_MsgUtilsConfigFileMachineName object |
|
62 */ |
|
63 EXPORT_C CT_MsgUtilsConfigFileMachineName* CT_MsgUtilsConfigFileMachineName::NewLC(const TDesC& aPtrEmailAdd) |
|
64 { |
|
65 CT_MsgUtilsConfigFileMachineName* self = new (ELeave) CT_MsgUtilsConfigFileMachineName(); |
|
66 CleanupStack::PushL(self); |
|
67 self->ConstructL(aPtrEmailAdd); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 /** |
|
73 CT_MsgUtilsConfigFileMachineName() |
|
74 Constructor |
|
75 */ |
|
76 EXPORT_C CT_MsgUtilsConfigFileMachineName::CT_MsgUtilsConfigFileMachineName() |
|
77 { |
|
78 } |
|
79 |
|
80 |
|
81 /** |
|
82 ConstructL() |
|
83 Reads the machine name from the Machine config file("c:\\smoketest\\MachineName.txt") |
|
84 and constructs the data members. |
|
85 |
|
86 @param aPtrEmailAdd |
|
87 */ |
|
88 EXPORT_C void CT_MsgUtilsConfigFileMachineName::ConstructL(const TDesC& aPtrEmailAdd) |
|
89 { |
|
90 RFs fs; |
|
91 User::LeaveIfError(fs.Connect()); |
|
92 CleanupClosePushL(fs); |
|
93 RFile file; |
|
94 User::LeaveIfError(file.Open(fs, KFileName, EFileRead)); |
|
95 |
|
96 CleanupClosePushL(file); |
|
97 TInt fileSize; |
|
98 User::LeaveIfError(file.Size(fileSize)); |
|
99 iMachineName = HBufC8::NewL(fileSize); |
|
100 TPtr8 bufferPtr = iMachineName->Des(); |
|
101 User::LeaveIfError(file.Read(bufferPtr)); |
|
102 |
|
103 if (aPtrEmailAdd.Compare(_L("NONE"))==0) |
|
104 iMachineNameEmail = HBufC::NewL(iMachineName->Length() + KAtEmailAddress.iTypeLength); |
|
105 else |
|
106 iMachineNameEmail = HBufC::NewL(iMachineName->Length() + aPtrEmailAdd.Length() + 1); |
|
107 |
|
108 iMachineNameEmail->Des().Copy(*iMachineName); |
|
109 |
|
110 if (aPtrEmailAdd.Compare(_L("NONE"))==0) |
|
111 iMachineNameEmail->Des().Append(KAtEmailAddress); |
|
112 else |
|
113 { |
|
114 iMachineNameEmail->Des().Append(_L("@")); |
|
115 iMachineNameEmail->Des().Append(aPtrEmailAdd); |
|
116 } |
|
117 |
|
118 |
|
119 CleanupStack::PopAndDestroy(2,&fs); |
|
120 } |
|
121 |
|
122 |
|
123 /** |
|
124 MachineNameEmail() |
|
125 Returns an email address with the host machine name. |
|
126 |
|
127 @return |
|
128 Email address of the machine |
|
129 */ |
|
130 EXPORT_C const TDesC& CT_MsgUtilsConfigFileMachineName::MachineNameEmail() |
|
131 { |
|
132 return (*iMachineNameEmail); |
|
133 } |
|
134 |
|
135 |
|
136 /** |
|
137 MachineName() |
|
138 Returns the host machine name |
|
139 |
|
140 @return |
|
141 Machine name |
|
142 */ |
|
143 EXPORT_C const TDesC8& CT_MsgUtilsConfigFileMachineName::MachineName() |
|
144 { |
|
145 return (*iMachineName); |
|
146 } |
|
147 |
|
148 |
|
149 /** |
|
150 ~CT_MsgUtilsConfigFileMachineName() |
|
151 Destructor |
|
152 */ |
|
153 CT_MsgUtilsConfigFileMachineName::~CT_MsgUtilsConfigFileMachineName() |
|
154 { |
|
155 delete iMachineName; |
|
156 delete iMachineNameEmail; |
|
157 } |