diff -r 6a20128ce557 -r ebfee66fde93 messagingapp/msgui/conversationview/src/msgviewutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/msgui/conversationview/src/msgviewutils.cpp Fri Jun 04 10:25:39 2010 +0100 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + +#include "msgviewutils.h" +#include "s60qconversions.h" + +// --------------------------------------------------------------------------- +// Constructor +// --------------------------------------------------------------------------- +// +MsgViewUtils::MsgViewUtils() +{ +} + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +MsgViewUtils::~MsgViewUtils() +{ +} + +// --------------------------------------------------------------------------- +// To get the mime type of the file +// +// --------------------------------------------------------------------------- +// +QString MsgViewUtils::mimeTypeL(QString aFileName) +{ + RFs rfs; + RFile file; + + HBufC* fileName = S60QConversions::qStringToS60Desc(aFileName); + + //TODO: The RFs and RApaLsSession has to be connected 1's, not for every mms + + if(rfs.Connect() != KErrNone) + return QString(); + + if(rfs.ShareProtected() != KErrNone ) + return QString(); + + if(file.Open(rfs, *fileName, EFileShareReadersOrWriters | EFileRead) != KErrNone ) + return QString(); + + TDataRecognitionResult dataType; + RApaLsSession apaSession; + + if(apaSession.Connect() == KErrNone) + { + if (apaSession.RecognizeData(file, dataType) == KErrNone) + { + TPtrC8 fileType = dataType.iDataType.Des8(); + + rfs.Close(); + apaSession.Close(); + + return S60QConversions::s60Desc8ToQString(fileType); + } + } + + rfs.Close(); + return QString(); +} + +//EOF