phonebookui/phonebookservices/src/cntserviceproviderold.cpp
changeset 59 a642906a277a
child 65 ae724a111993
equal deleted inserted replaced
47:7cbcb2896f0e 59:a642906a277a
       
     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 "cntserviceproviderold.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 CntServiceProviderOld::CntServiceProviderOld(CntServices& aServices, QObject *parent):
       
    28     XQServiceProvider(QLatin1String("com.nokia.services.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 CntServiceProviderOld::~CntServiceProviderOld()
       
    39 {
       
    40     CNT_ENTRY
       
    41     CNT_EXIT
       
    42 }
       
    43 
       
    44 /*!
       
    45 Launch fetch service with given parameters. OLD INTERFACE.
       
    46 */
       
    47 void CntServiceProviderOld::fetch(const QString &title, const QString &action, const QString& /*filter*/)
       
    48 {
       
    49     CNT_ENTRY
       
    50     // Ignore the filter parameter
       
    51     mCurrentRequestIndex = setCurrentRequestAsync();
       
    52     mServices.setQuittable(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 CntServiceProviderOld::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.setQuittable(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 CntServiceProviderOld::editCreateNew(const QString& definitionName, const QString& value)
       
    77 {
       
    78     CNT_ENTRY
       
    79     mCurrentRequestIndex = setCurrentRequestAsync();
       
    80     mServices.setQuittable(requestInfo().isEmbedded());
       
    81     mServices.editCreateNew( definitionName, value, *this, false ); // defaultForOnlineAccountIsImpp = false
       
    82     CNT_EXIT
       
    83 }
       
    84 
       
    85 void CntServiceProviderOld::editCreateNew(const QString &vCardFile)
       
    86 {
       
    87     CNT_ENTRY
       
    88     mCurrentRequestIndex = setCurrentRequestAsync();
       
    89     mServices.setQuittable(requestInfo().isEmbedded());
       
    90     mServices.editCreateNewFromVCard( vCardFile, *this );
       
    91     CNT_EXIT
       
    92 }
       
    93 
       
    94 
       
    95 /*!
       
    96 Launch contact selection view with a given detail (selecting detail there opens the editor and adds the new detail)
       
    97 */
       
    98 void CntServiceProviderOld::editUpdateExisting(const QString &definitionName, const QString &value)
       
    99 {
       
   100     CNT_ENTRY
       
   101     mCurrentRequestIndex = setCurrentRequestAsync();
       
   102     mServices.setQuittable(requestInfo().isEmbedded());
       
   103     mServices.editUpdateExisting( definitionName, value, *this, false ); // defaultForOnlineAccountIsImpp = false
       
   104     CNT_EXIT
       
   105 }
       
   106 
       
   107 
       
   108 /*!
       
   109 Launch communication launcher view for the contact with the given ID (QContactLocalId -> int)
       
   110 */
       
   111 void CntServiceProviderOld::open(int contactId)
       
   112 {
       
   113     CNT_ENTRY
       
   114     mCurrentRequestIndex = setCurrentRequestAsync();
       
   115     mServices.setQuittable(requestInfo().isEmbedded());
       
   116     mServices.launchContactCard( contactId, *this );
       
   117     CNT_EXIT
       
   118 }
       
   119 
       
   120 /*!
       
   121   Launch temporary communication launcher view with the given detail.
       
   122 */
       
   123 void CntServiceProviderOld::open(const QString &definitionName, const QString &value)
       
   124 {
       
   125     CNT_ENTRY
       
   126     mCurrentRequestIndex = setCurrentRequestAsync();
       
   127     mServices.setQuittable(requestInfo().isEmbedded());
       
   128     mServices.launchTemporaryContactCard( definitionName, value, *this ); // definitionName = field type      value = actual field value for prefilling editor
       
   129     CNT_EXIT
       
   130 }
       
   131 
       
   132 
       
   133 void CntServiceProviderOld::CompleteServiceAndCloseApp(const QVariant& retValue)
       
   134 {
       
   135     CNT_ENTRY
       
   136     connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
       
   137     if ( mCurrentRequestIndex != 0 )
       
   138     {
       
   139         CNT_LOG_ARGS("next, completing request.")
       
   140         const bool success = completeRequest(mCurrentRequestIndex, retValue);
       
   141         if ( !success )
       
   142         {
       
   143             CNT_LOG_ARGS("Failed to complete highway request.");
       
   144         }
       
   145         mCurrentRequestIndex = 0;
       
   146     }
       
   147     CNT_EXIT
       
   148 }
       
   149 
       
   150 // end of file