phonebookui/phonebookservices/src/cntserviceprovideredit.cpp
changeset 59 a642906a277a
child 75 4ecbe3571b5a
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: This class offers contact viewing UI services.
       
    15  *
       
    16  */
       
    17 
       
    18 #include "cntserviceprovideredit.h"
       
    19 #include "cntservices.h"
       
    20 #include "cntservicestrings.h"
       
    21 #include "cntdebug.h"
       
    22 
       
    23 #include <qapplication.h>
       
    24 #include <QPixmap>
       
    25 #include <QFile>
       
    26 #include <QUrl>
       
    27 
       
    28 CntServiceProviderEdit::CntServiceProviderEdit(CntServices& aServices, QObject *parent):
       
    29     XQServiceProvider(QLatin1String(KCntServiceInterfaceEdit), parent),
       
    30     mServices(aServices),
       
    31     mCurrentRequestIndex(0)
       
    32 {
       
    33     CNT_ENTRY
       
    34     publishAll();
       
    35     connect(this, SIGNAL(clientDisconnected()), &mServices, SLOT(quitApp()));
       
    36     CNT_EXIT
       
    37 }
       
    38 
       
    39 CntServiceProviderEdit::~CntServiceProviderEdit()
       
    40 {
       
    41     CNT_ENTRY
       
    42     CNT_EXIT
       
    43 }
       
    44 
       
    45 void CntServiceProviderEdit::editCreateNew(const QString& definitionName, const QString& value)
       
    46     {
       
    47     CNT_ENTRY
       
    48     mCurrentRequestIndex = setCurrentRequestAsync();
       
    49     mServices.setQuittable(requestInfo().isEmbedded());
       
    50     mServices.editCreateNew( definitionName, value, *this );
       
    51     CNT_EXIT
       
    52     }
       
    53 
       
    54 void CntServiceProviderEdit::editCreateNew(const QString& definitionName, const QString& value, const QString &subType)
       
    55     {
       
    56     CNT_ENTRY
       
    57     mCurrentRequestIndex = setCurrentRequestAsync();
       
    58     mServices.setQuittable(requestInfo().isEmbedded());
       
    59     mServices.editCreateNew( definitionName, value, subType, *this );
       
    60     CNT_EXIT
       
    61     }
       
    62 
       
    63 void CntServiceProviderEdit::editCreateNewFromVCard(const QString &vCardFile)
       
    64     {
       
    65     CNT_ENTRY
       
    66     mCurrentRequestIndex = setCurrentRequestAsync();
       
    67     mServices.setQuittable(requestInfo().isEmbedded());
       
    68     mServices.editCreateNewFromVCard( vCardFile, *this );
       
    69     CNT_EXIT
       
    70     }
       
    71 
       
    72 void CntServiceProviderEdit::editExisting(int contactId)
       
    73     {
       
    74     CNT_ENTRY
       
    75     mCurrentRequestIndex = setCurrentRequestAsync();
       
    76     mServices.setQuittable(requestInfo().isEmbedded());
       
    77     mServices.editExisting( contactId, *this );
       
    78     CNT_EXIT
       
    79     }
       
    80 
       
    81 void CntServiceProviderEdit::editUpdateExisting(const QString &definitionName, const QString &value)
       
    82     {
       
    83     CNT_ENTRY
       
    84     mCurrentRequestIndex = setCurrentRequestAsync();
       
    85     mServices.setQuittable(requestInfo().isEmbedded());
       
    86     mServices.editUpdateExisting( definitionName, value, *this );
       
    87     CNT_EXIT
       
    88     }
       
    89 
       
    90 void CntServiceProviderEdit::editUpdateExisting(const QString &definitionName, const QString &value, const QString &subType)
       
    91     {
       
    92     CNT_ENTRY
       
    93     mCurrentRequestIndex = setCurrentRequestAsync();
       
    94     mServices.setQuittable(requestInfo().isEmbedded());
       
    95     mServices.editUpdateExisting( definitionName, value, subType, *this );
       
    96     CNT_EXIT
       
    97     }
       
    98 
       
    99 void CntServiceProviderEdit::CompleteServiceAndCloseApp(const QVariant& retValue)
       
   100     {
       
   101     CNT_ENTRY
       
   102     connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
       
   103     if ( mCurrentRequestIndex != 0 )
       
   104         {
       
   105         const bool success = completeRequest(mCurrentRequestIndex, retValue);
       
   106         if ( !success )
       
   107         {
       
   108             CNT_LOG_ARGS("Failed to complete highway request.");
       
   109         }
       
   110         mCurrentRequestIndex = 0;
       
   111         }
       
   112     CNT_EXIT
       
   113     }