phonebookui/phonebookservices/src/cntserviceproviderold2.cpp
changeset 50 77bc263e1626
child 53 e6aff7b69165
equal deleted inserted replaced
49:74b30151afd6 50:77bc263e1626
       
     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 "cntserviceproviderold2.h"
       
    19 #include "cntservices.h"
       
    20 #include "cntdebug.h"
       
    21 
       
    22 #include <qapplication.h>
       
    23 #include <QPixmap>
       
    24 #include <QFile>
       
    25 #include <QUrl>
       
    26 
       
    27 CntServiceProviderOld2::CntServiceProviderOld2(CntServices& aServices, QObject *parent):
       
    28     XQServiceProvider(QLatin1String("phonebookservices.Fetch"), parent),
       
    29     mServices(aServices),
       
    30     mCurrentRequestIndex(0)
       
    31 {
       
    32     CNT_ENTRY
       
    33     publishAll();
       
    34     connect(this, SIGNAL(clientDisconnected()), &mServices, SLOT(quitApp()));
       
    35     CNT_EXIT
       
    36 }
       
    37 
       
    38 CntServiceProviderOld2::~CntServiceProviderOld2()
       
    39 {
       
    40     CNT_ENTRY
       
    41     CNT_EXIT
       
    42 }
       
    43 
       
    44 /*!
       
    45 Launch fetch service with given parameters. OLD INTERFACE.
       
    46 */
       
    47 void CntServiceProviderOld2::fetch(const QString &title, const QString &action, const QString& /*filter*/)
       
    48 {
       
    49     CNT_ENTRY
       
    50     // Ignore the filter parameter
       
    51     mCurrentRequestIndex = setCurrentRequestAsync();
       
    52     mServices.setQuitable(requestInfo().isEmbedded());
       
    53     mServices.multiFetch( title, action, *this );
       
    54     CNT_EXIT
       
    55 }
       
    56 
       
    57 
       
    58 /*
       
    59 Launch fetch service with given parameters. Fetching mode is No-select by default. OLD INTERFACE.
       
    60 */
       
    61 void CntServiceProviderOld2::Dofetch(const QString &title, const QString &action, const QString& /*filter*/, const QString& /*mode*/)
       
    62 {
       
    63     CNT_ENTRY
       
    64     // Ignore the filter parameter
       
    65     // Ignoring fourth argument, because it's not needed. DoFetch() by old contract is only for single-fetching.
       
    66     mCurrentRequestIndex = setCurrentRequestAsync();
       
    67     mServices.setQuitable(requestInfo().isEmbedded());
       
    68     mServices.singleFetch( title, action, *this );
       
    69     CNT_EXIT
       
    70 }
       
    71 
       
    72 
       
    73 /*
       
    74 Launch new contact editor with a given detail
       
    75 */
       
    76 void CntServiceProviderOld2::editCreateNew(const QString& definitionName, const QString& value)
       
    77 {
       
    78     CNT_ENTRY
       
    79     mCurrentRequestIndex = setCurrentRequestAsync();
       
    80     mServices.setQuitable(requestInfo().isEmbedded());
       
    81     mServices.editCreateNew( definitionName, value, *this );
       
    82 }
       
    83 
       
    84 void CntServiceProviderOld2::editCreateNew(const QString &vCardFile)
       
    85 {
       
    86     CNT_ENTRY
       
    87     mCurrentRequestIndex = setCurrentRequestAsync();
       
    88     mServices.setQuitable(requestInfo().isEmbedded());
       
    89     mServices.editCreateNewFromVCard( vCardFile, *this );
       
    90     CNT_EXIT
       
    91 }
       
    92 
       
    93 
       
    94 /*!
       
    95 Launch contact selection view with a given detail (selecting detail there opens the editor and adds the new detail)
       
    96 */
       
    97 void CntServiceProviderOld2::editUpdateExisting(const QString &definitionName, const QString &value)
       
    98 {
       
    99     CNT_ENTRY
       
   100     mCurrentRequestIndex = setCurrentRequestAsync();
       
   101     mServices.setQuitable(requestInfo().isEmbedded());
       
   102     mServices.editUpdateExisting( definitionName, value, *this );
       
   103     CNT_EXIT
       
   104 }
       
   105 
       
   106 
       
   107 /*!
       
   108 Launch communication launcher view for the contact with the given ID (QContactLocalId -> int)
       
   109 */
       
   110 void CntServiceProviderOld2::open(int contactId)
       
   111 {
       
   112     CNT_ENTRY
       
   113     mCurrentRequestIndex = setCurrentRequestAsync();
       
   114     mServices.setQuitable(requestInfo().isEmbedded());
       
   115     mServices.launchContactCard( contactId, *this );
       
   116     CNT_EXIT
       
   117 }
       
   118 
       
   119 /*!
       
   120   Launch temporary communication launcher view with the given detail.
       
   121 */
       
   122 void CntServiceProviderOld2::open(const QString &definitionName, const QString &value)
       
   123 {
       
   124     CNT_ENTRY
       
   125     mCurrentRequestIndex = setCurrentRequestAsync();
       
   126     mServices.setQuitable(requestInfo().isEmbedded());
       
   127     mServices.launchTemporaryContactCard( definitionName, value, *this ); // definitionName = field type      value = actual field value for prefilling editor
       
   128     CNT_EXIT
       
   129 }
       
   130 
       
   131 
       
   132 void CntServiceProviderOld2::CompleteServiceAndCloseApp(const QVariant& retValue)
       
   133 {
       
   134     CNT_ENTRY
       
   135     connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
       
   136     if ( mCurrentRequestIndex != 0 )
       
   137     {
       
   138         CNT_LOG_ARGS("next, completing request.")
       
   139         const bool success = completeRequest(mCurrentRequestIndex, retValue);
       
   140         if ( !success )
       
   141         {
       
   142             CNT_LOG_ARGS("Failed to complete highway request.");
       
   143         }
       
   144         mCurrentRequestIndex = 0;
       
   145     }
       
   146     CNT_EXIT
       
   147 }
       
   148 
       
   149 
       
   150 // end of file