messagingapp/msgui/conversationview/src/msgviewutils.cpp
changeset 31 ebfee66fde93
parent 23 238255e8b033
child 37 518b245aa84c
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     1 /*
       
     2  * Copyright (c) 2009 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  *
       
    16  */
       
    17 
       
    18 #include "msgviewutils.h"
       
    19 #include "s60qconversions.h"
       
    20 
       
    21 // ---------------------------------------------------------------------------
       
    22 // Constructor
       
    23 // ---------------------------------------------------------------------------
       
    24 //
       
    25 MsgViewUtils::MsgViewUtils()
       
    26 {
       
    27 }
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // Destructor
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 MsgViewUtils::~MsgViewUtils()
       
    34 {
       
    35 }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // To get the mime type of the file
       
    39 //
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 QString MsgViewUtils::mimeTypeL(QString aFileName)
       
    43 {
       
    44     RFs rfs;
       
    45     RFile file;
       
    46 
       
    47     HBufC* fileName = S60QConversions::qStringToS60Desc(aFileName);
       
    48 
       
    49     //TODO: The RFs and RApaLsSession has to be connected 1's, not for every mms
       
    50 
       
    51     if(rfs.Connect() != KErrNone)
       
    52         return QString();
       
    53 
       
    54     if(rfs.ShareProtected() != KErrNone )
       
    55         return QString();
       
    56 
       
    57     if(file.Open(rfs, *fileName, EFileShareReadersOrWriters | EFileRead) != KErrNone )
       
    58         return QString();
       
    59 
       
    60     TDataRecognitionResult dataType;
       
    61     RApaLsSession apaSession;
       
    62 
       
    63     if(apaSession.Connect() == KErrNone)
       
    64         {
       
    65         if (apaSession.RecognizeData(file, dataType) == KErrNone)
       
    66             {
       
    67             TPtrC8 fileType = dataType.iDataType.Des8();
       
    68 
       
    69             rfs.Close();
       
    70             apaSession.Close();
       
    71 
       
    72             return S60QConversions::s60Desc8ToQString(fileType);
       
    73             }
       
    74         }
       
    75 
       
    76     rfs.Close();
       
    77     return QString();
       
    78 }
       
    79 
       
    80 //EOF