|
1 /* |
|
2 * Copyright (c) 2008 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <msvstd.h> |
|
20 #include <charconv.h> |
|
21 #include <mmssettings.h> |
|
22 #include <mmsapplicationadapter.h> |
|
23 |
|
24 #include "logger.h" |
|
25 #include "jstringutils.h" |
|
26 #include "s60commonutils.h" |
|
27 #include "javasymbianoslayer.h" |
|
28 #include "mmspropertyretriever.h" |
|
29 |
|
30 namespace java |
|
31 { |
|
32 namespace wma |
|
33 { |
|
34 |
|
35 /* ----------------------------------------------------------------------------- |
|
36 * CJavaMmsPropertyRetriever::retrieveMsgCenter |
|
37 * Retrieves the MMSC URL used in |
|
38 * sending/receiving of multimedia messages. |
|
39 * ----------------------------------------------------------------------------- |
|
40 */ |
|
41 jstring MmsPropertyRetriever::retrieveMsgCenter(JNIEnv& aJni) |
|
42 { |
|
43 JELOG2(EWMA); |
|
44 jstring mmscNum = 0; |
|
45 HBufC* messageCenterNum = 0; |
|
46 CActiveScheduler* activeScheduler = 0; |
|
47 // An Active scheduler should be installed before creation of |
|
48 // CMmsApplicationAdapter . Check for activeScheduler installed |
|
49 // if not install. |
|
50 if (!CActiveScheduler::Current()) |
|
51 { |
|
52 activeScheduler = new CActiveScheduler() ; |
|
53 CActiveScheduler::Install(activeScheduler); |
|
54 } |
|
55 TRAPD(error, |
|
56 { |
|
57 CMmsApplicationAdapter* mMmsApplicationAdapter = |
|
58 CMmsApplicationAdapter::NewL(); |
|
59 mMmsApplicationAdapter->MmscUrlL(messageCenterNum); |
|
60 delete mMmsApplicationAdapter; |
|
61 }); |
|
62 if (KErrNone == error) |
|
63 { |
|
64 if (messageCenterNum) |
|
65 { |
|
66 mmscNum = java::util::S60CommonUtils::NativeToJavaString(aJni, |
|
67 *messageCenterNum); |
|
68 } |
|
69 } |
|
70 delete messageCenterNum; |
|
71 delete activeScheduler; |
|
72 return mmscNum; |
|
73 } |
|
74 |
|
75 /* ----------------------------------------------------------------------------- |
|
76 * CJavaMmsRetriever::retrieveMaxMMSSize |
|
77 * Retrieves the maximum size of a multimedia message which can be |
|
78 * sent/received . |
|
79 * ----------------------------------------------------------------------------- |
|
80 */ |
|
81 int MmsPropertyRetriever::retrieveMaxMMSSize() |
|
82 { |
|
83 JELOG2(EWMA); |
|
84 CMmsSettings* mmsSettings = CMmsSettings::NewL(); |
|
85 CleanupStack::PushL(mmsSettings); |
|
86 mmsSettings->LoadSettingsL(); |
|
87 int maxMMSSize = mmsSettings->MaximumSendSize(); |
|
88 CleanupStack::PopAndDestroy(mmsSettings); |
|
89 return maxMMSSize; |
|
90 } |
|
91 |
|
92 /* ----------------------------------------------------------------------------- |
|
93 * CJavaMmsRetriever::isValidEncoding |
|
94 * Checks if the provided parameter points to a valid encoding which |
|
95 * could be used to encode a certain part/attachment of a multimedia |
|
96 * message. Symbians's character converter component(CCnvCharacterSetConverter) |
|
97 * is used for validating the encoding. |
|
98 * ----------------------------------------------------------------------------- |
|
99 */ |
|
100 bool MmsPropertyRetriever::isValidEncoding(JNIEnv& aJni, |
|
101 jstring aContentEncoding) |
|
102 { |
|
103 JELOG2(EWMA); |
|
104 bool isValidEncoding = false; |
|
105 TInt result = KErrNone; |
|
106 TRAP(result, |
|
107 { |
|
108 RFs fileServer; |
|
109 // initialize the handle to the file server |
|
110 User::LeaveIfError(fileServer.Connect()); |
|
111 JStringUtils encoding(aJni,aContentEncoding); |
|
112 // convert the TPtrC to TPtrC8 |
|
113 HBufC8* nEncoding = HBufC8::NewL(encoding.Length()); |
|
114 CleanupStack::PushL(nEncoding); |
|
115 TPtr8 ptr(nEncoding->Des()); |
|
116 ptr.Copy(encoding); |
|
117 CCnvCharacterSetConverter* cConv = CCnvCharacterSetConverter::NewL(); |
|
118 CleanupStack::PushL(cConv); |
|
119 TUint charSetID = |
|
120 cConv->ConvertStandardNameOfCharacterSetToIdentifierL(ptr,fileServer); |
|
121 if (charSetID != 0) |
|
122 { |
|
123 // check that a corresponding MIBEnum has been found |
|
124 TUint mibEnum = cConv->ConvertCharacterSetIdentifierToMibEnumL( |
|
125 charSetID,fileServer); |
|
126 if (mibEnum != 0) |
|
127 { |
|
128 // corresponding encoding has been found |
|
129 isValidEncoding = true; |
|
130 } |
|
131 } |
|
132 fileServer.Close(); |
|
133 CleanupStack::PopAndDestroy(cConv); |
|
134 CleanupStack::PopAndDestroy(nEncoding); |
|
135 }); |
|
136 return isValidEncoding; |
|
137 } |
|
138 |
|
139 } //namespace wma |
|
140 } //namespace java |
|
141 // end of file |