os/ossrv/genericservices/mimerecognitionfw/apmime/APMSTD.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1997-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 <s32strm.h>
sl@0
    17
sl@0
    18
#include "APMSTD.H"
sl@0
    19
#include "APMPAN.H"
sl@0
    20
sl@0
    21
//
sl@0
    22
// class TDataType
sl@0
    23
//
sl@0
    24
sl@0
    25
EXPORT_C TDataType::TDataType()
sl@0
    26
	:iDataType(),
sl@0
    27
	iUid(KNullUid)
sl@0
    28
/** Default constructor.
sl@0
    29
sl@0
    30
Sets an empty data type string and sets the associated UID to KNullUid. */
sl@0
    31
	{}
sl@0
    32
sl@0
    33
EXPORT_C TDataType::TDataType(const TDataType& aDataType)
sl@0
    34
	:iDataType(aDataType.iDataType),
sl@0
    35
	iUid(aDataType.iUid)
sl@0
    36
/** Copy constructor.
sl@0
    37
sl@0
    38
@param aDataType The data type to be copied. */
sl@0
    39
	{}
sl@0
    40
sl@0
    41
EXPORT_C TDataType::TDataType(const TDesC8& aDataType)
sl@0
    42
	:iDataType(aDataType),
sl@0
    43
	iUid(KNullUid)
sl@0
    44
/** Constructor taking a descriptor.
sl@0
    45
sl@0
    46
The data type string is copied from the specified descriptor. By default, 
sl@0
    47
the associated UID is set to KNullUid.
sl@0
    48
sl@0
    49
If the data type string begins with the characters "x-epoc/x-app", identifying 
sl@0
    50
data as a native Symbian type, then the associated UID is set to the UID value 
sl@0
    51
which is expected to follow the characters "x-epoc/x-app".
sl@0
    52
sl@0
    53
If no sensible UID can be extracted from the characters following: "x-epoc/x-app", 
sl@0
    54
then the associated UID is set to KNullUid.
sl@0
    55
sl@0
    56
@param aDataType The source for the data type string. Note that this is an 
sl@0
    57
8 bit descriptor. */
sl@0
    58
	{
sl@0
    59
	ParseDes();
sl@0
    60
	}
sl@0
    61
sl@0
    62
EXPORT_C TDataType::TDataType(TUid aUid)
sl@0
    63
	:iUid(aUid)
sl@0
    64
/** Constructor taking a UID.
sl@0
    65
sl@0
    66
The data type string is set to "x-epoc/x-app" concatenated with the decimal 
sl@0
    67
character representation of the specified UID value. The data type is assumed 
sl@0
    68
to identify data as a native Symbian type.
sl@0
    69
sl@0
    70
@param aUid The associated UID. */
sl@0
    71
	{
sl@0
    72
	iDataType=KApaAppTypeDes;
sl@0
    73
	iDataType.AppendNum(STATIC_CAST(TInt,iUid.iUid));
sl@0
    74
	}
sl@0
    75
sl@0
    76
EXPORT_C TInt TDataType::operator==(const TDataType& aDataType) const
sl@0
    77
/** Compares this data type for equality with the specified data type.
sl@0
    78
sl@0
    79
Two data types are equal if their data type strings are the same. Text is 
sl@0
    80
folded for the purpose of the comparison, removing accents and converting 
sl@0
    81
letters to a common case form.
sl@0
    82
sl@0
    83
@param aDataType The data type taking part in the comparison.
sl@0
    84
@return True, if the data types are equal; false, otherwise. */
sl@0
    85
	{
sl@0
    86
	return (iDataType.CompareF(aDataType.iDataType)==0);
sl@0
    87
	}
sl@0
    88
sl@0
    89
EXPORT_C TInt TDataType::operator!=(const TDataType& aDataType) const
sl@0
    90
/** Compares this data type for inequality with the specified data type.
sl@0
    91
sl@0
    92
Two data types are only equal if their data type strings are the same. Text 
sl@0
    93
is folded for the purpose of the comparison, removing accents and converting 
sl@0
    94
letters to a common case form.
sl@0
    95
sl@0
    96
@param aDataType The data type taking part in the comparison.
sl@0
    97
@return True, if the data types are not equal; false, otherwise. */
sl@0
    98
	{
sl@0
    99
	return iDataType.CompareF(aDataType.iDataType);
sl@0
   100
	}
sl@0
   101
sl@0
   102
EXPORT_C TBool TDataType::IsNative() const
sl@0
   103
/** Tests whether the data type is a native Symbian type.
sl@0
   104
sl@0
   105
@return True, if the data type is a native Symbian type; false, otherwise. */
sl@0
   106
	{
sl@0
   107
	return iUid!=KNullUid;
sl@0
   108
	}
sl@0
   109
sl@0
   110
EXPORT_C TUid TDataType::Uid() const
sl@0
   111
/** Gets the UID associated with this data type.
sl@0
   112
sl@0
   113
@return The UID. */
sl@0
   114
	{
sl@0
   115
	return iUid;
sl@0
   116
	}
sl@0
   117
sl@0
   118
EXPORT_C TBuf<KMaxDataTypeLength> TDataType::Des() const
sl@0
   119
/** Gets a copy of the data type string.
sl@0
   120
sl@0
   121
@return A modifiable buffer descriptor containing a copy of the data type 
sl@0
   122
string. Note that this descriptor is a build independent type. */
sl@0
   123
	{
sl@0
   124
#ifdef _UNICODE
sl@0
   125
	TBuf16<KMaxDataTypeLength> buf;
sl@0
   126
	buf.Copy(iDataType);
sl@0
   127
	return buf;
sl@0
   128
#else
sl@0
   129
	return iDataType;
sl@0
   130
#endif // _UNICODE
sl@0
   131
	}
sl@0
   132
sl@0
   133
EXPORT_C TPtrC8 TDataType::Des8() const
sl@0
   134
/** Gets an 8 bit non-modifiable pointer descriptor to the data type string.
sl@0
   135
sl@0
   136
@return A pointer descriptor to the data type string. */
sl@0
   137
	{
sl@0
   138
	return iDataType;
sl@0
   139
	}
sl@0
   140
sl@0
   141
void TDataType::ParseDes()
sl@0
   142
	{
sl@0
   143
	TInt desLen=KApaAppTypeDes.Length();
sl@0
   144
	if (iDataType.Length()<=desLen)
sl@0
   145
		iUid=KNullUid;
sl@0
   146
	else
sl@0
   147
		{
sl@0
   148
		if (iDataType.Left(desLen).CompareF(KApaAppTypeDes)==0)
sl@0
   149
			{
sl@0
   150
			TLex8 lex(iDataType);
sl@0
   151
			lex.SkipAndMark(desLen);
sl@0
   152
			TInt err=lex.Val(iUid.iUid);
sl@0
   153
			if (err!=KErrNone)
sl@0
   154
				iUid=KNullUid;
sl@0
   155
			}
sl@0
   156
		}
sl@0
   157
	}
sl@0
   158
sl@0
   159
EXPORT_C void TDataType::InternalizeL(RReadStream& aReadStream)
sl@0
   160
/** Internalizes the data type from a stream.
sl@0
   161
sl@0
   162
The presence of this function means that the standard templated stream operator>>() 
sl@0
   163
is available to internalize objects of this class.
sl@0
   164
sl@0
   165
@param aReadStream The read stream. */
sl@0
   166
	{
sl@0
   167
	aReadStream >> iDataType;
sl@0
   168
	ParseDes();
sl@0
   169
	}
sl@0
   170
sl@0
   171
EXPORT_C void TDataType::ExternalizeL(RWriteStream& aWriteStream) const
sl@0
   172
/** Externalizes the data type to a stream.
sl@0
   173
sl@0
   174
The presence of this function means that the standard templated stream operator<<() 
sl@0
   175
is available to externalise objects of this class.
sl@0
   176
sl@0
   177
@param aWriteStream The write stream. */
sl@0
   178
	{
sl@0
   179
	aWriteStream << iDataType;
sl@0
   180
	}
sl@0
   181
sl@0
   182
//
sl@0
   183
// class TDataTypeWithPriority
sl@0
   184
//
sl@0
   185
sl@0
   186
/** Default constructor */
sl@0
   187
EXPORT_C TDataTypeWithPriority::TDataTypeWithPriority()
sl@0
   188
	{
sl@0
   189
	}
sl@0
   190
sl@0
   191
/** Constructor taking a data type and a priority value.
sl@0
   192
sl@0
   193
@param aDataType The data type.
sl@0
   194
@param aPriority The priority value. */
sl@0
   195
EXPORT_C TDataTypeWithPriority::TDataTypeWithPriority(const TDataType& aDataType, TDataTypePriority aPriority)
sl@0
   196
	: iDataType(aDataType),
sl@0
   197
	iPriority(aPriority)
sl@0
   198
	{}
sl@0
   199
	
sl@0
   200
/** Internalizes the data type from a stream.
sl@0
   201
sl@0
   202
The presence of this function means that the standard templated stream operator>>() 
sl@0
   203
is available to internalize objects of this class.
sl@0
   204
sl@0
   205
@param aReadStream The read stream. */
sl@0
   206
EXPORT_C void TDataTypeWithPriority::InternalizeL(RReadStream& aReadStream)
sl@0
   207
	{
sl@0
   208
	aReadStream >> iDataType;
sl@0
   209
	aReadStream >> iPriority;
sl@0
   210
	}
sl@0
   211
sl@0
   212
/** Externalizes the data type to a stream.
sl@0
   213
sl@0
   214
The presence of this function means that the standard templated stream operator<<() 
sl@0
   215
is available to externalise objects of this class.
sl@0
   216
sl@0
   217
@param aWriteStream The write stream. */
sl@0
   218
EXPORT_C void TDataTypeWithPriority::ExternalizeL(RWriteStream& aWriteStream) const
sl@0
   219
	{
sl@0
   220
	aWriteStream << iDataType;
sl@0
   221
	aWriteStream << iPriority;
sl@0
   222
	}
sl@0
   223
sl@0
   224
GLDEF_C void Panic(TApmPanic aPanic)
sl@0
   225
//
sl@0
   226
// Panic the process with APMIME as the category.
sl@0
   227
//
sl@0
   228
	{
sl@0
   229
	_LIT(KApMimePanicCat,"APMIME");
sl@0
   230
	User::Panic(KApMimePanicCat,aPanic);
sl@0
   231
	}
sl@0
   232
sl@0
   233