emailuis/nmailui/src/nmattachmentpicker.cpp
changeset 20 ecc8def7944a
child 23 2dc6caa42ec3
equal deleted inserted replaced
18:578830873419 20:ecc8def7944a
       
     1 /*
       
     2 * Copyright (c) 2009 - 2010 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: Utility class for launching different file pickers
       
    15 *
       
    16 */
       
    17 
       
    18 #include "nmuiheaders.h"
       
    19 
       
    20 
       
    21 /*!
       
    22     \class NmAttachmentPicker
       
    23     \brief Attachment picker for mail editor
       
    24 */
       
    25 
       
    26 /*!
       
    27     Constructor
       
    28 */
       
    29 NmAttachmentPicker::NmAttachmentPicker(QObject* parent):
       
    30     QObject(parent),
       
    31     mRequest(NULL)
       
    32 {
       
    33 }
       
    34 
       
    35 /*!
       
    36     Destructor
       
    37 */
       
    38 NmAttachmentPicker::~NmAttachmentPicker()
       
    39 {
       
    40     delete mRequest;
       
    41 }
       
    42 
       
    43 /*!
       
    44     Send request to start Photo picker 
       
    45 */
       
    46 void NmAttachmentPicker::fetchImage()
       
    47 {
       
    48     fetch(IMAGE_FETCHER_INTERFACE, IMAGE_FETCHER_OPERATION);
       
    49 }
       
    50 
       
    51 /*!
       
    52     Send request to start Music picker 
       
    53 */
       
    54 void NmAttachmentPicker::fetchAudio()
       
    55 {
       
    56     fetch(AUDIO_FETCHER_INTERFACE, AUDIO_FETCHER_OPERATION);    
       
    57 }
       
    58 
       
    59 /*!
       
    60     Send request to start Video picker 
       
    61 */
       
    62 void NmAttachmentPicker::fetchVideo()
       
    63 {
       
    64 
       
    65 }
       
    66 
       
    67 /*!
       
    68     Send request to start general file picker 
       
    69 */
       
    70 void NmAttachmentPicker::fetchOther()
       
    71 {
       
    72 
       
    73 }
       
    74 
       
    75 /*!
       
    76     Construct & send appmgr request to start appropriate picker   
       
    77 */
       
    78 void NmAttachmentPicker::fetch(const QString& interface, 
       
    79     const QString& operation)
       
    80 {
       
    81     if (mRequest) {
       
    82         delete mRequest;
       
    83         mRequest = NULL;
       
    84     }	
       
    85     mRequest = mAppmgr.create(interface, operation, true);
       
    86 
       
    87     if (mRequest) {
       
    88         mRequest->setSynchronous(false);
       
    89         connect(mRequest, SIGNAL(requestOk(const QVariant&)),
       
    90                 this, SIGNAL(attachmentsFetchOk(const QVariant&)));
       
    91 
       
    92         connect(mRequest, SIGNAL(requestError(int, const QString&)),
       
    93                 this, SIGNAL(attachmentsFetchError(int, const QString&)));
       
    94         
       
    95         if (!(mRequest)->send()) {
       
    96             //sending request failed
       
    97             NMLOG("appmgr: send request failed");
       
    98         }
       
    99     }
       
   100     else {
       
   101         //create request failed
       
   102         NMLOG("appmgr: create request failed");
       
   103     }      	  
       
   104 }