|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Namespace structure for Phonebook AIW Providers helper functions |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <AiwGenericParam.h> |
|
23 #include "PbkProviderUtils.h" |
|
24 #include "PbkAiwProviders.hrh" |
|
25 |
|
26 /// Unnamed namespace for local definitions |
|
27 namespace __RVCT_UNS_PbkProviderUtils { |
|
28 |
|
29 // LOCAL CONSTANTS |
|
30 enum TPanicCode |
|
31 { |
|
32 EPanicPreCond_CopyAndReplaceChars = 1, |
|
33 }; |
|
34 |
|
35 _LIT(KMimeTypeImage, "IMAGE"); |
|
36 _LIT(KMimeTypeAudio, "AUDIO"); |
|
37 |
|
38 _LIT(KMimeTypeRingingTone, "APPLICATION/VND.NOKIA.RINGING-TONE"); |
|
39 |
|
40 #ifdef RD_VIDEO_AS_RINGING_TONE |
|
41 _LIT(KMimeTypeVideo, "VIDEO"); |
|
42 _LIT(KMimeTypeRealMedia, "APPLICATION/VND.RN-REALMEDIA"); |
|
43 _LIT(KMimeTypeSDP, "APPLICATION/SDP"); |
|
44 _LIT(KMimeTypeFlash, "APPLICATION/X-SHOCKWAVE-FLASH"); |
|
45 #endif // RD_VIDEO_AS_RINGING_TONE |
|
46 |
|
47 |
|
48 |
|
49 // ================= LOCAL FUNCTIONS ======================= |
|
50 #ifdef _DEBUG |
|
51 void Panic(TPanicCode aReason) |
|
52 { |
|
53 _LIT(KPanicText, "PbkProviderUtils"); |
|
54 User::Panic(KPanicText, aReason); |
|
55 } |
|
56 #endif |
|
57 } |
|
58 |
|
59 using namespace __RVCT_UNS_PbkProviderUtils; |
|
60 |
|
61 |
|
62 // ================= MEMBER FUNCTIONS ======================= |
|
63 |
|
64 TInt PbkProviderUtils::MapMimeTypeL |
|
65 (const TDesC& aMimeTypeString) |
|
66 { |
|
67 _LIT(KSeparator, "/"); |
|
68 |
|
69 // Check for a type separator in the string |
|
70 TInt pos = aMimeTypeString.Find(KSeparator); |
|
71 // Leave if no separator was found.. the MIME |
|
72 // standard requires it |
|
73 User::LeaveIfError(pos); |
|
74 |
|
75 // Copy the full Mime type string (needed for uppercase) |
|
76 HBufC* fullBuf = aMimeTypeString.AllocLC(); |
|
77 TPtr fullString = fullBuf->Des(); |
|
78 fullString.UpperCase(); |
|
79 |
|
80 // Construct the compare string |
|
81 TPtrC extractString(aMimeTypeString.Left(pos)); |
|
82 HBufC* compareBuf = extractString.AllocLC(); |
|
83 TPtr compareString = compareBuf->Des(); |
|
84 compareString.UpperCase(); |
|
85 |
|
86 // Perform the comparison |
|
87 TInt ret = EPbkMimeTypeNotSupported; |
|
88 // Mime type case: IMAGE/* |
|
89 if (compareString.CompareF(KMimeTypeImage) == 0) |
|
90 { |
|
91 ret = EPbkMimeTypeImage; |
|
92 } |
|
93 // Mime type case: AUDIO/* |
|
94 else if (compareString.CompareF(KMimeTypeAudio) == 0) |
|
95 { |
|
96 ret = EPbkMimeTypeAudio; |
|
97 } |
|
98 // Mime type case: APPLICATION/VND.NOKIA.RINGING-TONE |
|
99 else if (fullString.CompareF(KMimeTypeRingingTone) == 0) |
|
100 { |
|
101 ret = EPbkMimeTypeRingingTone; |
|
102 } |
|
103 |
|
104 #ifdef RD_VIDEO_AS_RINGING_TONE |
|
105 |
|
106 // Mime type case: VIDEO/* |
|
107 else if (compareString.CompareF(KMimeTypeVideo) == 0) |
|
108 { |
|
109 ret = EPbkMimeTypeVideo; |
|
110 } |
|
111 // Mime type case: Special video formats |
|
112 else if ( (fullString.CompareF(KMimeTypeRealMedia) == 0) || |
|
113 (fullString.CompareF(KMimeTypeSDP) == 0) || |
|
114 (fullString.CompareF(KMimeTypeFlash) == 0) ) |
|
115 { |
|
116 ret = EPbkMimeTypeVideo; |
|
117 } |
|
118 |
|
119 #endif // RD_VIDEO_AS_RINGING_TONE |
|
120 |
|
121 CleanupStack::PopAndDestroy(compareBuf); |
|
122 CleanupStack::PopAndDestroy(fullBuf); |
|
123 |
|
124 return ret; |
|
125 } |
|
126 |
|
127 TPtrC PbkProviderUtils::GetAiwParamAsDescriptor( |
|
128 const CAiwGenericParamList& aParamList, |
|
129 TGenericParamId aParamType) |
|
130 { |
|
131 TInt index = 0; |
|
132 const TAiwGenericParam* genericParam = NULL; |
|
133 genericParam = aParamList.FindFirst( |
|
134 index, |
|
135 aParamType, |
|
136 EVariantTypeDesC); |
|
137 |
|
138 if (index >= 0 && genericParam) |
|
139 { |
|
140 // Get the data |
|
141 return genericParam->Value().AsDes(); |
|
142 } |
|
143 else |
|
144 { |
|
145 return KNullDesC(); |
|
146 } |
|
147 } |
|
148 |
|
149 // End of File |